aboutsummaryrefslogtreecommitdiffstats
path: root/src/nativewindow
diff options
context:
space:
mode:
authorMichael Bien <[email protected]>2010-04-22 23:24:18 +0200
committerMichael Bien <[email protected]>2010-04-22 23:24:18 +0200
commitca6818d87ee86b2cc9961e47ad9f899e1fd90f78 (patch)
tree0f664b7777d1a01364944c9864720bee0560ebc2 /src/nativewindow
parent26b0449cbc7db9961af92397f79e2b85f79ddb24 (diff)
reviewed X11Lib.XLock/UnlockDisplay() usage:
- added lock(); try{foo();}finally{unlock();} where missing - made sure lock is called outside the try block - fixed nesting in situations with two independent locks
Diffstat (limited to 'src/nativewindow')
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/impl/x11/X11GraphicsConfigurationFactory.java4
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/x11/X11GraphicsScreen.java33
2 files changed, 23 insertions, 14 deletions
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/impl/x11/X11GraphicsConfigurationFactory.java b/src/nativewindow/classes/com/jogamp/nativewindow/impl/x11/X11GraphicsConfigurationFactory.java
index 4ffda2fae..a6f52f3c0 100644
--- a/src/nativewindow/classes/com/jogamp/nativewindow/impl/x11/X11GraphicsConfigurationFactory.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/impl/x11/X11GraphicsConfigurationFactory.java
@@ -58,8 +58,8 @@ public class X11GraphicsConfigurationFactory extends GraphicsConfigurationFactor
int num[] = { -1 };
long display = screen.getDevice().getHandle();
+ X11Lib.XLockDisplay(display);
try {
- X11Lib.XLockDisplay(display);
XVisualInfo[] xvis = X11Lib.XGetVisualInfoCopied(display, X11Lib.VisualIDMask|X11Lib.VisualScreenMask, xvi_temp, num, 0);
if(xvis==null || num[0]<1) {
@@ -90,8 +90,8 @@ public class X11GraphicsConfigurationFactory extends GraphicsConfigurationFactor
vinfo_template.setC_class(c_class);
long display = screen.getDevice().getHandle();
+ X11Lib.XLockDisplay(display);
try {
- X11Lib.XLockDisplay(display);
XVisualInfo[] vinfos = X11Lib.XGetVisualInfoCopied(display, X11Lib.VisualScreenMask, vinfo_template, num, 0);
XVisualInfo best=null;
int rdepth = capabilities.getRedBits() + capabilities.getGreenBits() + capabilities.getBlueBits() + capabilities.getAlphaBits();
diff --git a/src/nativewindow/classes/javax/media/nativewindow/x11/X11GraphicsScreen.java b/src/nativewindow/classes/javax/media/nativewindow/x11/X11GraphicsScreen.java
index 69ace3c52..58b40efe0 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/x11/X11GraphicsScreen.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/x11/X11GraphicsScreen.java
@@ -57,13 +57,16 @@ public class X11GraphicsScreen extends DefaultGraphicsScreen implements Cloneabl
/** Creates a new X11GraphicsScreen using a thread local display connection */
public static AbstractGraphicsScreen createDefault() {
NativeWindowFactory.getDefaultFactory().getToolkitLock().lock();
- long display = X11Util.createThreadLocalDefaultDisplay();
try {
+ long display = X11Util.createThreadLocalDefaultDisplay();
X11Lib.XLockDisplay(display);
- int scrnIdx = X11Lib.DefaultScreen(display);
- return createScreenDevice(display, scrnIdx);
+ try{
+ int scrnIdx = X11Lib.DefaultScreen(display);
+ return createScreenDevice(display, scrnIdx);
+ }finally{
+ X11Lib.XUnlockDisplay(display);
+ }
} finally {
- X11Lib.XUnlockDisplay(display);
NativeWindowFactory.getDefaultFactory().getToolkitLock().unlock();
}
}
@@ -71,13 +74,16 @@ public class X11GraphicsScreen extends DefaultGraphicsScreen implements Cloneabl
public long getDefaultVisualID() {
// It still could be an AWT hold handle ..
NativeWindowFactory.getDefaultFactory().getToolkitLock().lock();
- long display = getDevice().getHandle();
try {
+ long display = getDevice().getHandle();
X11Lib.XLockDisplay(display);
- int scrnIdx = X11Lib.DefaultScreen(display);
- return X11Lib.DefaultVisualID(display, scrnIdx);
+ try{
+ int scrnIdx = X11Lib.DefaultScreen(display);
+ return X11Lib.DefaultVisualID(display, scrnIdx);
+ }finally{
+ X11Lib.XUnlockDisplay(display);
+ }
} finally {
- X11Lib.XUnlockDisplay(display);
NativeWindowFactory.getDefaultFactory().getToolkitLock().unlock();
}
}
@@ -85,14 +91,17 @@ public class X11GraphicsScreen extends DefaultGraphicsScreen implements Cloneabl
private static int fetchScreen(X11GraphicsDevice device, int screen) {
// It still could be an AWT hold handle ..
NativeWindowFactory.getDefaultFactory().getToolkitLock().lock();
- long display = device.getHandle();
try {
+ long display = device.getHandle();
X11Lib.XLockDisplay(display);
- if(X11Lib.XineramaEnabled(display)) {
- screen = 0; // Xinerama -> 1 screen
+ try{
+ if(X11Lib.XineramaEnabled(display)) {
+ screen = 0; // Xinerama -> 1 screen
+ }
+ }finally{
+ X11Lib.XUnlockDisplay(display);
}
} finally {
- X11Lib.XUnlockDisplay(display);
NativeWindowFactory.getDefaultFactory().getToolkitLock().unlock();
}
return screen;