diff options
author | Sven Gothel <[email protected]> | 2013-02-28 13:33:21 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2013-02-28 13:33:21 +0100 |
commit | 01fdd5c564dcb8a7d4f8347f71728f8c2b657cb3 (patch) | |
tree | 84a7784af6ad9de478aa3b33385f864a43f726fa /src/newt | |
parent | 3a4892c43be4a9dabba73d42175c2cfa39bd6d8d (diff) |
NEWT WindowImpl: Cleanup redundancies in destroy() and windowDestroyNotify(boolean)
- destroy()
- screen is never null!
- always attempt to removeScreenReference()
- windowDestroyNotify(boolean)
- NOP if !isNativeValid() to avoid DESTROY_* events
Diffstat (limited to 'src/newt')
-rw-r--r-- | src/newt/classes/jogamp/newt/WindowImpl.java | 69 |
1 files changed, 37 insertions, 32 deletions
diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index 66ca3e07d..af0bde179 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -892,21 +892,19 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer lifecycleHook.destroyActionInLock(); } - if( null != screen ) { - if( isNativeValid() ) { - screen.removeScreenModeListener(screenModeListenerImpl); - closeNativeImpl(); - final AbstractGraphicsDevice cfgADevice = config.getScreen().getDevice(); - if( cfgADevice != screen.getDisplay().getGraphicsDevice() ) { // don't pull display's device - cfgADevice.close(); // ensure a cfg's device is closed - } - setGraphicsConfiguration(null); - removeScreenReference(); - } - Display dpy = screen.getDisplay(); - if(null != dpy) { - dpy.validateEDT(); + if( isNativeValid() ) { + screen.removeScreenModeListener(screenModeListenerImpl); + closeNativeImpl(); + final AbstractGraphicsDevice cfgADevice = config.getScreen().getDevice(); + if( cfgADevice != screen.getDisplay().getGraphicsDevice() ) { // don't pull display's device + cfgADevice.close(); // ensure a cfg's device is closed } + setGraphicsConfiguration(null); + } + removeScreenReference(); + Display dpy = screen.getDisplay(); + if(null != dpy) { + dpy.validateEDT(); } // send synced destroyed notification @@ -2626,33 +2624,40 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer final WindowClosingMode defMode = getDefaultCloseOperation(); final WindowClosingMode mode = force ? WindowClosingMode.DISPOSE_ON_CLOSE : defMode; if(DEBUG_IMPLEMENTATION) { - System.err.println("Window.windowDestroyNotify(force: "+force+", mode "+defMode+" -> "+mode+") "+getThreadName()+": "+this); + System.err.println("Window.windowDestroyNotify(isNativeValid: "+isNativeValid()+", force: "+force+", mode "+defMode+" -> "+mode+") "+getThreadName()+": "+this); + // Thread.dumpStack(); } - if( WindowClosingMode.DISPOSE_ON_CLOSE == mode ) { - if(force) { - setDefaultCloseOperation(mode); - } - try { - if( null == windowDestroyNotifyAction ) { - destroy(); - } else { - windowDestroyNotifyAction.run(); - } - } finally { + final boolean destroyed; + + if( isNativeValid() ) { + if( WindowClosingMode.DISPOSE_ON_CLOSE == mode ) { if(force) { - setDefaultCloseOperation(defMode); + setDefaultCloseOperation(mode); } + try { + if( null == windowDestroyNotifyAction ) { + destroy(); + } else { + windowDestroyNotifyAction.run(); + } + } finally { + if(force) { + setDefaultCloseOperation(defMode); + } + } + } else { + // send synced destroy notifications + sendWindowEvent(WindowEvent.EVENT_WINDOW_DESTROY_NOTIFY); } + + destroyed = !isNativeValid(); } else { - // send synced destroy notifications - sendWindowEvent(WindowEvent.EVENT_WINDOW_DESTROY_NOTIFY); + destroyed = true; } - - final boolean destroyed = !isNativeValid(); if(DEBUG_IMPLEMENTATION) { - System.err.println("Window.windowDestroyNotify(force: "+force+", mode "+mode+") END "+getThreadName()+": destroyed "+destroyed+", "+this); + System.err.println("Window.windowDestroyNotify(isNativeValid: "+isNativeValid()+", force: "+force+", mode "+mode+") END "+getThreadName()+": destroyed "+destroyed+", "+this); } return destroyed; |