From 214daa8087d50e1d604fb8357c4eb8fe9e275423 Mon Sep 17 00:00:00 2001
From: Tim Mickel <tim.mickel@gmail.com>
Date: Mon, 6 Jun 2016 14:54:32 -0400
Subject: [PATCH] Always unset `topLevel` in deleteStack_

Blocks may have topLevel set even if they are not present in this.stacks
---
 src/engine/runtime.js | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/src/engine/runtime.js b/src/engine/runtime.js
index 55a13d33a..356adcba8 100644
--- a/src/engine/runtime.js
+++ b/src/engine/runtime.js
@@ -365,11 +365,9 @@ Runtime.prototype._addStack = function (id) {
  */
 Runtime.prototype._deleteStack = function (id) {
     var i = this.stacks.indexOf(id);
-    if (i > -1) {
-        this.stacks.splice(i, 1);
-        // Update `topLevel` property on the top block.
-        this.blocks[id].topLevel = false;
-    }
+    if (i > -1) this.stacks.splice(i, 1);
+    // Update `topLevel` property on the top block.
+    if (this.blocks[id]) this.blocks[id].topLevel = false;
 };
 
 /**