Stop calling onchange on deleted blocks.

This commit is contained in:
Neil Fraser
2015-07-13 14:16:09 -07:00
parent daa7145ee4
commit 64bd9d498d
6 changed files with 20 additions and 31 deletions

View File

@@ -310,13 +310,9 @@ Blockly.Blocks['logic_compare'] = {
* @this Blockly.Block
*/
onchange: function() {
if (!this.workspace) {
// Block has been deleted.
return;
}
var blockA = this.getInputTargetBlock('A');
var blockB = this.getInputTargetBlock('B');
// Kick blocks that existed prior to this change if they don't match.
// Disconnect blocks that existed prior to this change if they don't match.
if (blockA && blockB &&
!blockA.outputConnection.checkType_(blockB.outputConnection)) {
// Mismatch between two inputs. Disconnect previous and bump it away.
@@ -445,14 +441,10 @@ Blockly.Blocks['logic_ternary'] = {
* @this Blockly.Block
*/
onchange: function() {
if (!this.workspace) {
// Block has been deleted.
return;
}
var blockA = this.getInputTargetBlock('THEN');
var blockB = this.getInputTargetBlock('ELSE');
var parentConnection = this.outputConnection.targetConnection;
// Kick blocks that existed prior to this change if they don't match.
// Disconnect blocks that existed prior to this change if they don't match.
if ((blockA || blockB) && parentConnection) {
for (var i = 0; i < 2; i++) {
var block = (i == 1) ? blockA : blockB;

View File

@@ -295,12 +295,8 @@ Blockly.Blocks['controls_flow_statements'] = {
* @this Blockly.Block
*/
onchange: function() {
if (!this.workspace) {
// Block has been deleted.
return;
}
var legal = false;
// Is the block nested in a control statement?
// Is the block nested in a loop?
var block = this;
do {
if (block.type == 'controls_repeat' ||

View File

@@ -733,10 +733,6 @@ Blockly.Blocks['procedures_ifreturn'] = {
* @this Blockly.Block
*/
onchange: function() {
if (!this.workspace) {
// Block has been deleted.
return;
}
var legal = false;
// Is the block nested in a procedure?
var block = this;