From 8a850ea69d90fa68efecb52ba8dc6ec3938505d7 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 26 Sep 2010 02:32:02 +0200 Subject: NEWT: Fix WindowImpl: Bring back 'isValid()' test no screen!=null in destroy() ; DisplayImpl: refCount reset --- src/newt/classes/com/jogamp/newt/impl/DisplayImpl.java | 2 ++ src/newt/classes/com/jogamp/newt/impl/WindowImpl.java | 18 ++++++++++++------ 2 files changed, 14 insertions(+), 6 deletions(-) (limited to 'src/newt') diff --git a/src/newt/classes/com/jogamp/newt/impl/DisplayImpl.java b/src/newt/classes/com/jogamp/newt/impl/DisplayImpl.java index 894b9a201..eeb0b2504 100644 --- a/src/newt/classes/com/jogamp/newt/impl/DisplayImpl.java +++ b/src/newt/classes/com/jogamp/newt/impl/DisplayImpl.java @@ -78,6 +78,7 @@ public abstract class DisplayImpl extends Display { display.name = name; display.type=type; display.destroyWhenUnused=false; + display.refCount=0; synchronized(displayList) { display.id = serialno++; display.fqname = getFQName(display.id, display.type, display.name); @@ -184,6 +185,7 @@ public abstract class DisplayImpl extends Display { edtUtil.reset(); } aDevice = null; + refCount=0; if(DEBUG) { dumpDisplayList("Display.destroy("+getFQName()+") END"); } diff --git a/src/newt/classes/com/jogamp/newt/impl/WindowImpl.java b/src/newt/classes/com/jogamp/newt/impl/WindowImpl.java index 3939a12fb..d3ff2e558 100644 --- a/src/newt/classes/com/jogamp/newt/impl/WindowImpl.java +++ b/src/newt/classes/com/jogamp/newt/impl/WindowImpl.java @@ -513,13 +513,15 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } public void destroy(boolean unrecoverable) { - if(DEBUG_IMPLEMENTATION) { - String msg = new String("Window.destroy(unrecoverable: "+unrecoverable+") START "+getThreadName()/*+", "+this*/); - System.err.println(msg); - //Exception ee = new Exception(msg); - //ee.printStackTrace(); + if( isValid() ) { + if(DEBUG_IMPLEMENTATION) { + String msg = new String("Window.destroy(unrecoverable: "+unrecoverable+") START "+getThreadName()/*+", "+this*/); + System.err.println(msg); + //Exception ee = new Exception(msg); + //ee.printStackTrace(); + } + runOnEDTIfAvail(true, new DestroyAction(unrecoverable)); } - runOnEDTIfAvail(true, new DestroyAction(unrecoverable)); } class DestroyAction implements Runnable { @@ -530,6 +532,10 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer public void run() { windowLock.lock(); try { + if( !isValid() ) { + return; // nop + } + // Childs first .. synchronized(childWindowsLock) { // avoid ConcurrentModificationException: parent -> child -> parent.removeChild(this) -- cgit v1.2.3