Merge pull request #1821 from paulkaplan/fix-variable-monitor-switching

Fix an issue where the targetId of a monitor could be reassigned
This commit is contained in:
Paul Kaplan 2018-12-06 05:32:11 -05:00 committed by GitHub
commit 9e57404222
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -625,18 +625,22 @@ class Blocks {
// Variable blocks may be sprite specific depending on the owner of the variable // Variable blocks may be sprite specific depending on the owner of the variable
let isSpriteLocalVariable = false; let isSpriteLocalVariable = false;
if (block.opcode === 'data_variable') { if (block.opcode === 'data_variable') {
isSpriteLocalVariable = !optRuntime.getEditingTarget().isStage && isSpriteLocalVariable = !(optRuntime.getTargetForStage().variables[block.fields.VARIABLE.id]);
optRuntime.getEditingTarget().variables[block.fields.VARIABLE.id];
} else if (block.opcode === 'data_listcontents') { } else if (block.opcode === 'data_listcontents') {
isSpriteLocalVariable = !optRuntime.getEditingTarget().isStage && isSpriteLocalVariable = !(optRuntime.getTargetForStage().variables[block.fields.LIST.id]);
optRuntime.getEditingTarget().variables[block.fields.LIST.id];
} }
const isSpriteSpecific = isSpriteLocalVariable || const isSpriteSpecific = isSpriteLocalVariable ||
(optRuntime.monitorBlockInfo.hasOwnProperty(block.opcode) && (optRuntime.monitorBlockInfo.hasOwnProperty(block.opcode) &&
optRuntime.monitorBlockInfo[block.opcode].isSpriteSpecific); optRuntime.monitorBlockInfo[block.opcode].isSpriteSpecific);
block.targetId = isSpriteSpecific ? optRuntime.getEditingTarget().id : null; if (isSpriteSpecific) {
// If creating a new sprite specific monitor, the only possible target is
// the current editing one b/c you cannot dynamically create monitors.
// Also, do not change the targetId if it has already been assigned
block.targetId = block.targetId || optRuntime.getEditingTarget().id;
} else {
block.targetId = null;
}
if (wasMonitored && !block.isMonitored) { if (wasMonitored && !block.isMonitored) {
optRuntime.requestHideMonitor(block.id); optRuntime.requestHideMonitor(block.id);