From 9cd41199c5a1408a185d66b804820fc4d2575fb1 Mon Sep 17 00:00:00 2001 From: picklesrus Date: Wed, 26 Dec 2018 16:26:34 -0500 Subject: [PATCH] Fix #4203 by checking whether a target exists before asking whether it has an variables --- src/lib/blocks.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/lib/blocks.js b/src/lib/blocks.js index 601804c65..eadf6d6ff 100644 --- a/src/lib/blocks.js +++ b/src/lib/blocks.js @@ -260,8 +260,12 @@ export default function (vm) { return stageOptions.concat(stageVariableMenuItems); } // Get all the local variables (no lists) and add them to the menu. - const spriteVariableOptions = - vm.runtime.getSpriteTargetByName(selectedItem).getAllVariableNamesInScopeByType('', true); + const target = vm.runtime.getSpriteTargetByName(selectedItem); + let spriteVariableOptions = []; + // The target should exist, but there are ways for it not to (e.g. #4203). + if (target) { + spriteVariableOptions = target.getAllVariableNamesInScopeByType('', true); + } const spriteVariableMenuItems = spriteVariableOptions.map(variable => [variable, variable]); return spriteOptions.concat(spriteVariableMenuItems); }