From: Kevin Lamonte Date: Wed, 23 Aug 2017 01:51:56 +0000 (-0400) Subject: fix stack overflow X-Git-Tag: fanfix-swing-0.0.1~12^2~13^2~223 X-Git-Url: https://git.nikiroo.be/?a=commitdiff_plain;h=499fdccfad144aa58869d839d50edb898670626a;p=fanfix-swing.git fix stack overflow --- diff --git a/src/jexer/TApplication.java b/src/jexer/TApplication.java index 4457197c..b4c53ec3 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);