X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fjexer%2FTTerminalWidget.java;h=39d761c64a1b2ae06fe2df6a5cbd1a143a8b4b5e;hb=1e71bba21116ce83e76501c2e60f85ba6113e82d;hp=7a93f4e7b32320c69ade2090049146e9200fdef0;hpb=90d87fca1ee987e6650b90beafc7831cbca0a457;p=fanfix.git diff --git a/src/jexer/TTerminalWidget.java b/src/jexer/TTerminalWidget.java index 7a93f4e..39d761c 100644 --- a/src/jexer/TTerminalWidget.java +++ b/src/jexer/TTerminalWidget.java @@ -384,6 +384,14 @@ public class TTerminalWidget extends TScrollableWidget // Update the scroll bars reflowData(); + if (!isDrawable()) { + // We lost the connection, onShellExit() called an action + // that ultimately removed this widget from the UI + // hierarchy, so no one cares if we update the display. + // Bail out. + return; + } + if ((scrollback == null) || emulator.isReading()) { scrollback = copyBuffer(emulator.getScrollbackBuffer()); display = copyBuffer(emulator.getDisplayBuffer()); @@ -820,17 +828,19 @@ public class TTerminalWidget extends TScrollableWidget public void onShellExit() { TApplication app = getApplication(); if (app != null) { - app.invokeLater(new Runnable() { - public void run() { - if (closeAction != null) { + if (closeAction != null) { + // We have to put this action inside invokeLater() because it + // could be executed during draw() when syncing with ECMA48. + app.invokeLater(new Runnable() { + public void run() { closeAction.DO(TTerminalWidget.this); } - if (getApplication() != null) { - getApplication().postEvent(new TMenuEvent( - TMenu.MID_REPAINT)); - } - } - }); + }); + } + if (getApplication() != null) { + getApplication().postEvent(new TMenuEvent( + TMenu.MID_REPAINT)); + } } }