From 1ce97d1c50779cf9b84a89e0ce06057deb632e80 Mon Sep 17 00:00:00 2001 From: Beka Westberg Date: Mon, 4 Nov 2019 14:41:45 -0800 Subject: [PATCH] Added checking if the block is disposed before trying to reconnect in logic_compare block. --- blocks/logic.js | 4 ++-- core/block.js | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/blocks/logic.js b/blocks/logic.js index 89f2b2097..813e8f747 100644 --- a/blocks/logic.js +++ b/blocks/logic.js @@ -561,7 +561,7 @@ Blockly.Constants.Logic.LOGIC_COMPARE_ONCHANGE_MIXIN = { var prevA = this.prevBlocks_[0]; if (prevA !== blockA) { blockA.unplug(); - if (prevA && !prevA.isShadow()) { + if (prevA && !prevA.isDisposed() && !prevA.isShadow()) { // The shadow block is automatically replaced during unplug(). this.getInput('A').connection.connect(prevA.outputConnection); } @@ -569,7 +569,7 @@ Blockly.Constants.Logic.LOGIC_COMPARE_ONCHANGE_MIXIN = { var prevB = this.prevBlocks_[1]; if (prevB !== blockB) { blockB.unplug(); - if (prevB && !prevB.isShadow()) { + if (prevB && !prevB.isDisposed() && !prevB.isShadow()) { // The shadow block is automatically replaced during unplug(). this.getInput('B').connection.connect(prevB.outputConnection); } diff --git a/core/block.js b/core/block.js index 46893575a..fcb1da9c1 100644 --- a/core/block.js +++ b/core/block.js @@ -843,6 +843,14 @@ Blockly.Block.prototype.setEditable = function(editable) { } }; +/** + * Returns if this block has been disposed of / deleted. + * @return {boolean} True if this block has been disposed of / deleted. + */ +Blockly.Block.prototype.isDisposed = function() { + return this.disposed; +}; + /** * Find the connection on this block that corresponds to the given connection * on the other block.