mirror of
https://github.com/google/blockly.git
synced 2026-01-13 03:47:08 +01:00
Fix undoing function argument changes.
This commit is contained in:
@@ -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_();
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -423,6 +423,7 @@ Blockly.Events.Change.prototype.run = function(forward) {
|
||||
oldMutation = oldMutationDom && Blockly.Xml.domToText(oldMutationDom);
|
||||
}
|
||||
if (block.domToMutation) {
|
||||
value = value || '<mutation></mutation>';
|
||||
var dom = Blockly.Xml.textToDom('<xml>' + value + '</xml>');
|
||||
block.domToMutation(dom.firstChild);
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user