diff --git a/blocks/procedures.js b/blocks/procedures.js index c74c15f6a..cae8b78ba 100644 --- a/blocks/procedures.js +++ b/blocks/procedures.js @@ -504,10 +504,16 @@ Blockly.Blocks['procedures_callnoreturn'] = { // Existing param IDs. // Note that quarkConnections_ may include IDs that no longer exist, but // which might reappear if a param is reattached in the mutator. - if (!paramIds) { - // Reset the quarks (a mutator is about to open). + var defBlock = Blockly.Procedures.getDefinition(this.getProcedureCall(), + this.workspace); + var mutatorOpen = defBlock && defBlock.mutator && + defBlock.mutator.isVisible(); + if (!mutatorOpen) { this.quarkConnections_ = {}; this.quarkIds_ = null; + } + if (!paramIds) { + // Reset the quarks (a mutator is about to open). return; } if (goog.array.equals(this.arguments_, paramNames)) { @@ -539,7 +545,8 @@ Blockly.Blocks['procedures_callnoreturn'] = { if (input) { var connection = input.connection.targetConnection; this.quarkConnections_[this.quarkIds_[i]] = connection; - if (connection && paramIds.indexOf(this.quarkIds_[i]) == -1) { + if (mutatorOpen && connection && + paramIds.indexOf(this.quarkIds_[i]) == -1) { // This connection should no longer be attached to this block. connection.disconnect(); connection.getSourceBlock().bumpNeighbours_(); diff --git a/core/connection.js b/core/connection.js index eb2749218..14c07b36f 100644 --- a/core/connection.js +++ b/core/connection.js @@ -331,7 +331,8 @@ Blockly.Connection.prototype.checkConnection_ = function(target) { case Blockly.Connection.REASON_SELF_CONNECTION: throw 'Attempted to connect a block to itself.'; case Blockly.Connection.REASON_DIFFERENT_WORKSPACES: - throw 'Blocks are on different workspaces.'; + // Usually this means one block has been deleted. + throw 'Blocks not on same workspace.'; case Blockly.Connection.REASON_WRONG_TYPE: throw 'Attempt to connect incompatible types.'; case Blockly.Connection.REASON_TARGET_NULL: diff --git a/core/events.js b/core/events.js index 9cf8ee901..12179eb30 100644 --- a/core/events.js +++ b/core/events.js @@ -423,6 +423,7 @@ Blockly.Events.Change.prototype.run = function(forward) { oldMutation = oldMutationDom && Blockly.Xml.domToText(oldMutationDom); } if (block.domToMutation) { + value = value || ''; var dom = Blockly.Xml.textToDom('' + value + ''); block.domToMutation(dom.firstChild); } diff --git a/core/mutator.js b/core/mutator.js index 40f9221ec..91ef5814a 100644 --- a/core/mutator.js +++ b/core/mutator.js @@ -349,8 +349,8 @@ Blockly.Mutator.prototype.dispose = function() { * @return {boolean} True iff a reconnection was made, false otherwise. */ Blockly.Mutator.reconnect = function(connectionChild, block, inputName) { - if (!connectionChild) { - return false; + if (!connectionChild || !connectionChild.getSourceBlock().workspace) { + return false; // No connection or block has been deleted. } var connectionParent = block.getInput(inputName).connection; var currentParent = connectionChild.targetBlock();