From 0d86165122d1aeec4bc366d3f8545101d633017e Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Wed, 5 Aug 2015 05:02:37 -0700 Subject: [PATCH] ensure screen and program globals are reset. --- lib/program.js | 4 ++++ lib/widgets/screen.js | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/lib/program.js b/lib/program.js index 5928434..79e24b7 100644 --- a/lib/program.js +++ b/lib/program.js @@ -446,6 +446,10 @@ Program.prototype.destroy = function() { this.flush(); this._exiting = true; + if (Program.total === 1) { + Program.global = Program.instances[0]; + } + if (Program.total === 0) { Program.global = null; diff --git a/lib/widgets/screen.js b/lib/widgets/screen.js index 3904881..3993e42 100644 --- a/lib/widgets/screen.js +++ b/lib/widgets/screen.js @@ -391,6 +391,10 @@ Screen.prototype.destroy = function() { Screen.instances.splice(index, 1); Screen.total--; + if (Screen.total === 1) { + Screen.global = Screen.instances[0]; + } + if (Screen.total === 0) { Screen.global = null;