mirror of
https://github.com/moparisthebest/davmail
synced 2025-01-08 04:08:12 -05:00
Refactor SWT tray dispose management on exit
git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@2242 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
parent
1b7ae604fc
commit
a8a0ac3923
@ -29,6 +29,8 @@ import org.apache.log4j.lf5.LF5Appender;
|
|||||||
import org.apache.log4j.lf5.LogLevel;
|
import org.apache.log4j.lf5.LogLevel;
|
||||||
import org.apache.log4j.lf5.viewer.LogBrokerMonitor;
|
import org.apache.log4j.lf5.viewer.LogBrokerMonitor;
|
||||||
import org.eclipse.swt.SWT;
|
import org.eclipse.swt.SWT;
|
||||||
|
import org.eclipse.swt.events.DisposeEvent;
|
||||||
|
import org.eclipse.swt.events.DisposeListener;
|
||||||
import org.eclipse.swt.graphics.Image;
|
import org.eclipse.swt.graphics.Image;
|
||||||
import org.eclipse.swt.internal.gtk.OS;
|
import org.eclipse.swt.internal.gtk.OS;
|
||||||
import org.eclipse.swt.widgets.*;
|
import org.eclipse.swt.widgets.*;
|
||||||
@ -211,6 +213,19 @@ public class SwtGatewayTray implements DavGatewayTrayInterface {
|
|||||||
inactiveImage = loadSwtImage(AwtGatewayTray.TRAY_INACTIVE_PNG);
|
inactiveImage = loadSwtImage(AwtGatewayTray.TRAY_INACTIVE_PNG);
|
||||||
|
|
||||||
trayItem.setImage(image);
|
trayItem.setImage(image);
|
||||||
|
trayItem.addDisposeListener(new DisposeListener() {
|
||||||
|
public void widgetDisposed(DisposeEvent e) {
|
||||||
|
if (image != null && !image.isDisposed()) {
|
||||||
|
image.dispose();
|
||||||
|
}
|
||||||
|
if (image2 != null && !image2.isDisposed()) {
|
||||||
|
image2.dispose();
|
||||||
|
}
|
||||||
|
if (inactiveImage != null && !inactiveImage.isDisposed()) {
|
||||||
|
inactiveImage.dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// create a popup menu
|
// create a popup menu
|
||||||
final Menu popup = new Menu(shell, SWT.POP_UP);
|
final Menu popup = new Menu(shell, SWT.POP_UP);
|
||||||
@ -340,8 +355,16 @@ public class SwtGatewayTray implements DavGatewayTrayInterface {
|
|||||||
display.sleep();
|
display.sleep();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
dispose();
|
// dispose AWT frames
|
||||||
|
if (settingsFrame != null) {
|
||||||
|
settingsFrame.dispose();
|
||||||
|
}
|
||||||
|
if (aboutFrame != null) {
|
||||||
|
aboutFrame.dispose();
|
||||||
|
}
|
||||||
|
if (logBrokerMonitor != null) {
|
||||||
|
logBrokerMonitor.dispose();
|
||||||
}
|
}
|
||||||
} catch (Exception exc) {
|
} catch (Exception exc) {
|
||||||
DavGatewayTray.error(exc);
|
DavGatewayTray.error(exc);
|
||||||
@ -367,34 +390,6 @@ public class SwtGatewayTray implements DavGatewayTrayInterface {
|
|||||||
|
|
||||||
public void dispose() {
|
public void dispose() {
|
||||||
shell.dispose();
|
shell.dispose();
|
||||||
if (trayItem != null) {
|
|
||||||
trayItem.dispose();
|
|
||||||
trayItem = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (image != null) {
|
|
||||||
image.dispose();
|
|
||||||
}
|
|
||||||
if (image2 != null) {
|
|
||||||
image2.dispose();
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
if (!display.isDisposed()) {
|
|
||||||
display.dispose();
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
// already disposed
|
|
||||||
}
|
|
||||||
// dispose AWT frames
|
|
||||||
if (settingsFrame != null) {
|
|
||||||
settingsFrame.dispose();
|
|
||||||
}
|
|
||||||
if (aboutFrame != null) {
|
|
||||||
aboutFrame.dispose();
|
|
||||||
}
|
|
||||||
if (logBrokerMonitor != null) {
|
|
||||||
logBrokerMonitor.dispose();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user