X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fjexer%2FTApplication.java;h=264b8c8220e3fddb3b062e612a97ed74761f22c2;hb=abb84744979f74e96ec604357895fc3130aec913;hp=1b396a73eca33bd80f6cbfbc4765113e4783d7b3;hpb=d4bcb88c528504f04821e5c7b4c5e23b05843cb4;p=fanfix.git diff --git a/src/jexer/TApplication.java b/src/jexer/TApplication.java index 1b396a7..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; } @@ -1481,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), @@ -1810,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 ----------------------------------------------------- // ------------------------------------------------------------------------