Skip to content

Commit 9cd4119

Browse files
committed
Fix #4203 by checking whether a target exists before asking whether it has an variables
1 parent c50bb3c commit 9cd4119

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/lib/blocks.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,8 +260,12 @@ export default function (vm) {
260260
return stageOptions.concat(stageVariableMenuItems);
261261
}
262262
// Get all the local variables (no lists) and add them to the menu.
263-
const spriteVariableOptions =
264-
vm.runtime.getSpriteTargetByName(selectedItem).getAllVariableNamesInScopeByType('', true);
263+
const target = vm.runtime.getSpriteTargetByName(selectedItem);
264+
let spriteVariableOptions = [];
265+
// The target should exist, but there are ways for it not to (e.g. #4203).
266+
if (target) {
267+
spriteVariableOptions = target.getAllVariableNamesInScopeByType('', true);
268+
}
265269
const spriteVariableMenuItems = spriteVariableOptions.map(variable => [variable, variable]);
266270
return spriteOptions.concat(spriteVariableMenuItems);
267271
}

0 commit comments

Comments
 (0)