Skip to content

Renaming vars so that you get duplicate procedure vars breaks mutator (sometimes) #3767

@BeksOmega

Description

@BeksOmega

Describe the bug

If you rename a variable via a variable block, it can cause duplicate variables in a procedure.

To Reproduce

Steps to reproduce the behavior:

  1. Create a mutator with two variables.
  2. Grab a variable block for one of the variables.
  3. Rename the variable to match the other variable in the mutator.
  4. Observe how there are duplicate vars in the procedure. (bad)

The next bit does not always happen, depending on which var you rename:

  1. Open the mutator.
  2. Observe how you have two vars.
  3. Close the mutator and reopen.
  4. Observe how you get errors in the console.

Expected behavior

There are two parts:

  1. Duplicate vars: No clue how this should be handled.
  2. Errors: Errors are bad, definitely do not want errors.

Screenshots

Errors:
DuplicateVars

No Errors:
DuplicateVars2

Desktop (please complete the following information):

  • OS: Ubunto 18.04
  • Browser Chrome
  • Version 80

Stack Traces

procedures.js:110 Uncaught TypeError: Cannot read property 'name' of null
    at Blockly.BlockSvg.mutationToDom (procedures.js:110)
    at Object.Blockly.Procedures.mutateCallers (procedures.js:374)
    at Blockly.BlockSvg.compose (procedures.js:227)
    at Blockly.Mutator.workspaceChanged_ (mutator.js:377)
    at Blockly.WorkspaceSvg.Blockly.Workspace.fireChangeListener (workspace.js:657)
    at Blockly.Events.fireNow_ (events.js:192)
mutationToDom @ procedures.js:110
Blockly.Procedures.mutateCallers @ procedures.js:374
compose @ procedures.js:227
Blockly.Mutator.workspaceChanged_ @ mutator.js:377
Blockly.Workspace.fireChangeListener @ workspace.js:657
Blockly.Events.fireNow_ @ events.js:192
setTimeout (async)
Blockly.Events.fire @ events.js:174
Blockly.Mutator.setVisible @ mutator.js:274
Blockly.Icon.iconClick_ @ icon.js:124
Blockly.Mutator.iconClick_ @ mutator.js:124
wrapFunc @ blockly.js:462
variables.js:51 Uncaught TypeError: Cannot read property 'getId' of null
    at Object.Blockly.Variables.allUsedVarModels (variables.js:51)
    at Object.Blockly.Xml.workspaceToDom (xml.js:38)
    at exportWorkspace (my_playground.html:438)
    at autoUpdater (my_playground.html:561)
    at Blockly.WorkspaceSvg.Blockly.Workspace.fireChangeListener (workspace.js:657)
    at Blockly.Events.fireNow_ (events.js:192)
Blockly.Variables.allUsedVarModels @ variables.js:51
Blockly.Xml.workspaceToDom @ xml.js:38
exportWorkspace @ my_playground.html:438
autoUpdater @ my_playground.html:561
Blockly.Workspace.fireChangeListener @ workspace.js:657
Blockly.Events.fireNow_ @ events.js:192
setTimeout (async)
Blockly.Events.fire @ events.js:174
Blockly.Mutator.setVisible @ mutator.js:274
Blockly.Icon.iconClick_ @ icon.js:124
Blockly.Mutator.iconClick_ @ mutator.js:124
wrapFunc @ blockly.js:462
procedures.js:110 Uncaught TypeError: Cannot read property 'name' of null
    at Blockly.BlockSvg.mutationToDom (procedures.js:110)
    at Object.Blockly.Procedures.mutateCallers (procedures.js:374)
    at Blockly.BlockSvg.decompose (procedures.js:202)
    at Blockly.Mutator.setVisible (mutator.js:292)
    at Blockly.Mutator.Blockly.Icon.iconClick_ (icon.js:124)
    at Blockly.Mutator.iconClick_ (mutator.js:124)
    at SVGGElement.wrapFunc (blockly.js:462)
mutationToDom @ procedures.js:110
Blockly.Procedures.mutateCallers @ procedures.js:374
decompose @ procedures.js:202
Blockly.Mutator.setVisible @ mutator.js:292
Blockly.Icon.iconClick_ @ icon.js:124
Blockly.Mutator.iconClick_ @ mutator.js:124
wrapFunc @ blockly.js:462
variables.js:51 Uncaught TypeError: Cannot read property 'getId' of null
    at Object.Blockly.Variables.allUsedVarModels (variables.js:51)
    at Object.Blockly.Xml.workspaceToDom (xml.js:38)
    at exportWorkspace (my_playground.html:438)
    at autoUpdater (my_playground.html:561)
    at Blockly.WorkspaceSvg.Blockly.Workspace.fireChangeListener (workspace.js:657)
    at Blockly.Events.fireNow_ (events.js:192)

Additional context

N/A

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions