X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fjexer%2FTApplication.java;h=264b8c8220e3fddb3b062e612a97ed74761f22c2;hb=2a92cf977ee2ae37d8302a294c6338fa51a5ca45;hp=4c317f304d6bb82c6fc39684ce17be4ffc8b53ea;hpb=9696a8f6da9a0d204740420d6d8571176ab81944;p=nikiroo-utils.git diff --git a/src/jexer/TApplication.java b/src/jexer/TApplication.java index 4c317f3..264b8c8 100644 --- a/src/jexer/TApplication.java +++ b/src/jexer/TApplication.java @@ -638,6 +638,8 @@ public class TApplication implements Runnable { * Run this application until it exits. */ public void run() { + // System.err.println("*** TApplication.run() begins ***"); + // Start the main consumer thread primaryEventHandler = new WidgetEventHandler(this, true); (new Thread(primaryEventHandler)).start(); @@ -721,6 +723,11 @@ public class TApplication implements Runnable { // resources. closeAllWindows(); + // Give the overarching application an opportunity to release + // resources. + onExit(); + + // System.err.println("*** TApplication.run() exits ***"); } // ------------------------------------------------------------------------ @@ -914,7 +921,7 @@ public class TApplication implements Runnable { // Abort everything if (event instanceof TCommandEvent) { TCommandEvent command = (TCommandEvent) event; - if (command.getCmd().equals(cmAbort)) { + if (command.equals(cmAbort)) { exit(); return; } @@ -936,6 +943,7 @@ public class TApplication implements Runnable { if (desktop != null) { desktop.setDimensions(0, 0, resize.getWidth(), resize.getHeight() - 1); + desktop.onResize(resize); } // Change menu edges if needed. @@ -1480,7 +1488,7 @@ public class TApplication implements Runnable { String version = getClass().getPackage().getImplementationVersion(); if (version == null) { // This is Java 9+, use a hardcoded string here. - version = "0.3.0"; + version = "0.3.1"; } messageBox(i18n.getString("aboutDialogTitle"), MessageFormat.format(i18n.getString("aboutDialogText"), version), @@ -1809,6 +1817,14 @@ public class TApplication implements Runnable { } } + /** + * Subclasses can use this hook to cleanup resources. Called as the last + * step of TApplication.run(). + */ + public void onExit() { + // Default does nothing. + } + // ------------------------------------------------------------------------ // TWindow management ----------------------------------------------------- // ------------------------------------------------------------------------