mirror of
https://github.com/google/blockly.git
synced 2026-01-09 01:50:11 +01:00
Avoid crashing when a procedure input has an empty string
Fixes #1958 This will drop the input when it's in the empty string state. This causes the block to remove the input and re-add it when the text is reverted, but prevents the breakage. A followup fix should leave the input alone instead of removing it, but this works for now.
This commit is contained in:
@@ -159,7 +159,11 @@ Blockly.Blocks['procedures_defnoreturn'] = {
|
||||
this.arguments_.push(varName);
|
||||
var variable = Blockly.Variables.getOrCreateVariablePackage(
|
||||
this.workspace, varId, varName, '');
|
||||
this.argumentVarModels_.push(variable);
|
||||
if (variable != null) {
|
||||
this.argumentVarModels_.push(variable);
|
||||
} else {
|
||||
console.log('Failed to create a variable with name ' + varName + ', ignoring.');
|
||||
}
|
||||
}
|
||||
}
|
||||
this.updateParams_();
|
||||
@@ -216,7 +220,12 @@ Blockly.Blocks['procedures_defnoreturn'] = {
|
||||
var varName = paramBlock.getFieldValue('NAME');
|
||||
this.arguments_.push(varName);
|
||||
var variable = this.workspace.getVariable(varName, '');
|
||||
this.argumentVarModels_.push(variable);
|
||||
if (variable != null) {
|
||||
this.argumentVarModels_.push(variable);
|
||||
} else {
|
||||
console.log('Failed to get variable named ' + varName + ', ignoring.');
|
||||
}
|
||||
|
||||
this.paramIds_.push(paramBlock.id);
|
||||
paramBlock = paramBlock.nextConnection &&
|
||||
paramBlock.nextConnection.targetBlock();
|
||||
|
||||
Reference in New Issue
Block a user