aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2013-06-30 14:28:41 +0200
committerSven Gothel <[email protected]>2013-06-30 14:28:41 +0200
commit61ee606366f28843287049d01f3f1e2e2139878e (patch)
tree2edd8353348c4caccd58d616158b4c344b3aff34
parent3a0529c4713206dae130f2b1a6bf68b7a0fb3905 (diff)
ScreenImpl: Fix ScreenMonitorState add/remove reference, which shall only happen at actual native create and destroy.
.. otherwise usage of Screen.createNative() and a later Window creation would cause the ScreenMonitorState having 2 added listener - which in turn disables it's orig mode reset at Screen destruction.
-rw-r--r--src/newt/classes/jogamp/newt/ScreenImpl.java24
1 files changed, 11 insertions, 13 deletions
diff --git a/src/newt/classes/jogamp/newt/ScreenImpl.java b/src/newt/classes/jogamp/newt/ScreenImpl.java
index 28f3e876c..422d5b06c 100644
--- a/src/newt/classes/jogamp/newt/ScreenImpl.java
+++ b/src/newt/classes/jogamp/newt/ScreenImpl.java
@@ -177,7 +177,7 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener {
if(null == aScreen) {
throw new NativeWindowException("Screen.createNative() failed to instanciate an AbstractGraphicsScreen");
}
-
+
initMonitorState();
if(DEBUG) {
System.err.println("Screen.createNative() END ("+DisplayImpl.getThreadName()+", "+this+"), total "+ (System.nanoTime()-tCreated)/1e6 +"ms");
@@ -185,23 +185,22 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener {
synchronized(screenList) {
screensActive++;
}
+ ScreenMonitorState.getScreenMonitorState(this.getFQName()).addListener(this);
}
- ScreenMonitorState sms = ScreenMonitorState.getScreenMonitorState(this.getFQName());
- sms.addListener(this);
}
@Override
public synchronized final void destroy() {
- releaseMonitorState();
-
synchronized(screenList) {
- screenList.remove(this);
- if(0 < screensActive) {
- screensActive--;
+ if( screenList.remove(this) ) {
+ if(0 < screensActive) {
+ screensActive--;
+ }
}
}
if ( null != aScreen ) {
+ releaseMonitorState();
closeNativeImpl();
aScreen = null;
}
@@ -217,8 +216,7 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener {
}
if ( 0 == refCount ) {
createNative();
- }
- if(null == aScreen) {
+ } else if(null == aScreen) {
throw new NativeWindowException("Screen.addReference() (refCount "+refCount+") null AbstractGraphicsScreen");
}
return ++refCount;
@@ -538,9 +536,9 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener {
cache.monitorDevices.getOrAdd(monitor);
}
// Sort MonitorModes (all and per device) in descending order - default!
- MonitorModeUtil.sort(cache.monitorModes.getData(), false /* ascendingOrder*/);
+ MonitorModeUtil.sort(cache.monitorModes.getData(), false ); // descending order
for(Iterator<MonitorDevice> iMonitor=cache.monitorDevices.iterator(); iMonitor.hasNext(); ) {
- MonitorModeUtil.sort(iMonitor.next().getSupportedModes(), false /* ascendingOrder*/);
+ MonitorModeUtil.sort(iMonitor.next().getSupportedModes(), false ); // descending order
}
if(DEBUG) {
int i=0;
@@ -611,7 +609,7 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener {
return cache.monitorDevices.size();
}
- private void releaseMonitorState() {
+ private final void releaseMonitorState() {
ScreenMonitorState sms;
ScreenMonitorState.lockScreenMonitorState();
try {