aboutsummaryrefslogtreecommitdiffstats
path: root/src/nativewindow/classes
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2013-11-23 04:03:19 +0100
committerSven Gothel <[email protected]>2013-11-23 04:03:19 +0100
commit87fa56ba6f88b3f87199c70324b919dc4ae4e6cf (patch)
tree7a3a83bf93365450f11d39a4efe78d5d7696f632 /src/nativewindow/classes
parent94f3c1b5d3af65cf9d985833b2c8e40ec1af4592 (diff)
AWTWindowClosingProtocol: Hold Window reference impl. is listening to to properly removeClosingListener() (and replace boolean state)
Diffstat (limited to 'src/nativewindow/classes')
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTWindowClosingProtocol.java31
1 files changed, 14 insertions, 17 deletions
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTWindowClosingProtocol.java b/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTWindowClosingProtocol.java
index 27275c6e0..aadecb455 100644
--- a/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTWindowClosingProtocol.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTWindowClosingProtocol.java
@@ -40,11 +40,11 @@ import jogamp.nativewindow.awt.AWTMisc;
public class AWTWindowClosingProtocol implements WindowClosingProtocol {
- private Component comp;
- private Runnable closingOperationClose;
- private Runnable closingOperationNOP;
- private boolean closingListenerSet = false;
- private Object closingListenerLock = new Object();
+ private final Component comp;
+ private Window listenTo;
+ private final Runnable closingOperationClose;
+ private final Runnable closingOperationNOP;
+ private final Object closingListenerLock = new Object();
private WindowClosingMode defaultCloseOperation = WindowClosingMode.DISPOSE_ON_CLOSE;
private boolean defaultCloseOperationSetByUser = false;
@@ -55,6 +55,7 @@ public class AWTWindowClosingProtocol implements WindowClosingProtocol {
*/
public AWTWindowClosingProtocol(Component comp, Runnable closingOperationClose, Runnable closingOperationNOP) {
this.comp = comp;
+ this.listenTo = null;
this.closingOperationClose = closingOperationClose;
this.closingOperationNOP = closingOperationNOP;
}
@@ -86,13 +87,12 @@ public class AWTWindowClosingProtocol implements WindowClosingProtocol {
*/
public final boolean addClosingListener() throws IllegalStateException {
synchronized(closingListenerLock) {
- if(closingListenerSet) {
+ if(null != listenTo) {
throw new IllegalStateException("WindowClosingListener already set");
}
- final Window w = AWTMisc.getWindow(comp);
- if(null!=w) {
- w.addWindowListener(windowClosingAdapter);
- closingListenerSet = true;
+ listenTo = AWTMisc.getWindow(comp);
+ if(null!=listenTo) {
+ listenTo.addWindowListener(windowClosingAdapter);
return true;
}
}
@@ -101,13 +101,10 @@ public class AWTWindowClosingProtocol implements WindowClosingProtocol {
public final boolean removeClosingListener() {
synchronized(closingListenerLock) {
- if(closingListenerSet) {
- final Window w = AWTMisc.getWindow(comp);
- if(null!=w) {
- w.removeWindowListener(windowClosingAdapter);
- closingListenerSet = false;
- return true;
- }
+ if(null != listenTo) {
+ listenTo.removeWindowListener(windowClosingAdapter);
+ listenTo = null;
+ return true;
}
}
return false;