diff options
author | Sven Gothel <[email protected]> | 2010-09-25 15:06:26 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2010-09-25 15:06:26 +0200 |
commit | bcad73dccb1cd0c32e3a77b3406ddc74e8f2e4ac (patch) | |
tree | aac1f157781e4243acba7d11622344b6b84dafcf /src/newt/classes/com | |
parent | 1c02f0eeb539ff5de7259b822893ab63a9cc3ab0 (diff) |
Unit test for Bug 411 (Pre AWT/Swing Usage, Mixed usage with JOGL) - GLCanvas NPE fix - NewtCanvasAWT added destroy(..)
Unit test for Bug 411 (Pre AWT/Swing Usage, Mixed usage with JOGL):
Added exhausting Pre AWT/Swing usage test utilizing a later JOGL init
with GLCanvas and NEWTCanvasAWT.
This works for NV+X11+Ubuntu+64bit, have to do more testing.
GLCanvas NPE fix at destroy/dispose, check if already destroyed, ie context==null
NewtCanvasAWT: Add destroy() and destroy(boolean unrecoverable)
Diffstat (limited to 'src/newt/classes/com')
-rw-r--r-- | src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java | 42 |
1 files changed, 39 insertions, 3 deletions
diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java index fdb434889..de4ea2a30 100644 --- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java +++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java @@ -165,9 +165,7 @@ public class NewtCanvasAWT extends java.awt.Canvas { } if(add) { - if(null!=newtChild) { - parent = NewtFactoryAWT.getNativeWindow(this, newtChild.getRequestedCapabilities()); - } + parent = NewtFactoryAWT.getNativeWindow(this, newtChild.getRequestedCapabilities()); if(null!=parent) { if(DEBUG) { System.err.println("NewtCanvasAWT.reparentWindow: "+newtChild); @@ -188,6 +186,44 @@ public class NewtCanvasAWT extends java.awt.Canvas { } } + /** + * @see #destroy(boolean) + */ + public final void destroy() { + destroy(false); + } + + /** + * Destroys this resource: + * <ul> + * <li> Make the NEWT Child invisible </li> + * <li> Disconnects the NEWT Child from this Canvas NativeWindow, reparent to NULL </li> + * <li> Issues <code>destroy(unrecoverable)</code> on the NEWT Child</li> + * <li> Remove reference to the NEWT Child, if unrecoverable</li> + * <li> Remove this Canvas from it's parent.</li> + * </ul> + * @see Window#destroy() + * @see Window#destroy(boolean) + */ + public final void destroy(boolean unrecoverable) { + if(null!=newtChild) { + java.awt.Container cont = getContainer(this); + if(DEBUG) { + System.err.println("NewtCanvasAWT.destroy("+unrecoverable+"): "+newtChild+", from "+cont); + } + parent = null; + newtChild.setVisible(false); + newtChild.reparentWindow(null); + newtChild.destroy(unrecoverable); + if(unrecoverable) { + newtChild = null; + } + if(null!=cont) { + cont.remove(this); + } + } + } + public void paint(Graphics g) { if(null!=newtChild) { newtChild.windowRepaint(0, 0, getWidth(), getHeight()); |