From bcad73dccb1cd0c32e3a77b3406ddc74e8f2e4ac Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sat, 25 Sep 2010 15:06:26 +0200 Subject: 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) --- .../classes/com/jogamp/newt/awt/NewtCanvasAWT.java | 42 ++++++++++++++++++++-- 1 file changed, 39 insertions(+), 3 deletions(-) (limited to 'src/newt/classes/com/jogamp') 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: + * + * @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()); -- cgit v1.2.3