Make sure we do exit: catch exceptions before System.exit

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@589 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
mguessan 2009-06-16 08:55:39 +00:00
parent e5c1fcd807
commit 32bc5eeb02
3 changed files with 155 additions and 143 deletions

View File

@ -188,6 +188,7 @@ public class AwtGatewayTray implements DavGatewayTrayInterface {
// create an action exitListener to listen for exit action executed on the tray icon // create an action exitListener to listen for exit action executed on the tray icon
ActionListener exitListener = new ActionListener() { ActionListener exitListener = new ActionListener() {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
try {
DavGateway.stop(); DavGateway.stop();
SystemTray.getSystemTray().remove(trayIcon); SystemTray.getSystemTray().remove(trayIcon);
@ -197,6 +198,9 @@ public class AwtGatewayTray implements DavGatewayTrayInterface {
if (logBrokerMonitor != null) { if (logBrokerMonitor != null) {
logBrokerMonitor.dispose(); logBrokerMonitor.dispose();
} }
} catch (Exception exc) {
DavGatewayTray.error(exc);
}
// make sure we do exit // make sure we do exit
System.exit(0); System.exit(0);
} }

View File

@ -177,6 +177,7 @@ public class FrameGatewayTray implements DavGatewayTrayInterface {
// create an action exitListener to listen for exit action executed on the tray icon // create an action exitListener to listen for exit action executed on the tray icon
ActionListener exitListener = new ActionListener() { ActionListener exitListener = new ActionListener() {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
try {
DavGateway.stop(); DavGateway.stop();
// dispose frames // dispose frames
settingsFrame.dispose(); settingsFrame.dispose();
@ -184,6 +185,9 @@ public class FrameGatewayTray implements DavGatewayTrayInterface {
if (logBrokerMonitor != null) { if (logBrokerMonitor != null) {
logBrokerMonitor.dispose(); logBrokerMonitor.dispose();
} }
} catch (Exception exc) {
DavGatewayTray.error(exc);
}
// make sure we do exit // make sure we do exit
System.exit(0); System.exit(0);
} }

View File

@ -136,6 +136,7 @@ public class SwtGatewayTray implements DavGatewayTrayInterface {
new Thread("SWT") { new Thread("SWT") {
@Override @Override
public void run() { public void run() {
try {
display = new Display(); display = new Display();
shell = new Shell(display); shell = new Shell(display);
@ -282,10 +283,13 @@ public class SwtGatewayTray implements DavGatewayTrayInterface {
if (logBrokerMonitor != null) { if (logBrokerMonitor != null) {
logBrokerMonitor.dispose(); logBrokerMonitor.dispose();
} }
}
} catch (Exception exc) {
DavGatewayTray.error(exc);
}
// make sure we do exit // make sure we do exit
System.exit(0); System.exit(0);
} }
}
}.start(); }.start();
while (true) { while (true) {
// wait for SWT init // wait for SWT init