From 499fdccfad144aa58869d839d50edb898670626a Mon Sep 17 00:00:00 2001 From: Kevin Lamonte Date: Tue, 22 Aug 2017 21:51:56 -0400 Subject: [PATCH] fix stack overflow --- src/jexer/TApplication.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/jexer/TApplication.java b/src/jexer/TApplication.java index 4457197..b4c53ec 100644 --- a/src/jexer/TApplication.java +++ b/src/jexer/TApplication.java @@ -1431,9 +1431,15 @@ public class TApplication implements Runnable { if (activeWindow != null) { assert (activeWindow.getZ() == 0); - activeWindow.onUnfocus(); activeWindow.setActive(false); activeWindow.setZ(window.getZ()); + + // Unset activeWindow now before unfocus, so that a window + // lifecycle change inside onUnfocus() doesn't call + // switchWindow() and lead to a stack overflow. + TWindow oldActiveWindow = activeWindow; + activeWindow = null; + oldActiveWindow.onUnfocus(); } activeWindow = window; activeWindow.setZ(0); -- 2.27.0