mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-23 14:32:59 -05:00
Fix issue where deleting a sprite with a monitored local variable creates that local variable on all other sprites after switching sprites twice or more.
This commit is contained in:
parent
c21d5eba1c
commit
b95350da6e
1 changed files with 7 additions and 0 deletions
|
@ -852,7 +852,14 @@ class VirtualMachine extends EventEmitter {
|
|||
}
|
||||
const spritePromise = this.exportSprite(targetId, 'uint8array');
|
||||
const restoreSprite = () => spritePromise.then(spriteBuffer => this.addSprite(spriteBuffer));
|
||||
// Remove monitors from the runtime state and remove the
|
||||
// target-specific monitored blocks (e.g. local variables)
|
||||
this.runtime.requestRemoveMonitorByTargetId(targetId);
|
||||
const targetSpecificMonitorBlockIds = Object.keys(this.runtime.monitorBlocks._blocks)
|
||||
.filter(key => this.runtime.monitorBlocks._blocks[key].targetId === targetId);
|
||||
for (const blockId of targetSpecificMonitorBlockIds) {
|
||||
this.runtime.monitorBlocks.deleteBlock(blockId);
|
||||
}
|
||||
const currentEditingTarget = this.editingTarget;
|
||||
for (let i = 0; i < sprite.clones.length; i++) {
|
||||
const clone = sprite.clones[i];
|
||||
|
|
Loading…
Reference in a new issue