6880694: GraphicsDevice.setFullScreenWindow(null) throws NPE if there's a fullscreen window displayed
authordcherepanov
Wed, 11 Nov 2009 19:18:27 +0300
changeset 4265 8950a3d33a86
parent 4264 40c232605c68
child 4266 b105f9beb20f
6880694: GraphicsDevice.setFullScreenWindow(null) throws NPE if there's a fullscreen window displayed Summary: handle "empty" refresh rates Reviewed-by: art, anthony
jdk/src/solaris/native/sun/awt/awt_GraphicsEnv.c
--- a/jdk/src/solaris/native/sun/awt/awt_GraphicsEnv.c	Wed Nov 11 17:46:58 2009 +0300
+++ b/jdk/src/solaris/native/sun/awt/awt_GraphicsEnv.c	Wed Nov 11 19:18:27 2009 +0300
@@ -1654,6 +1654,7 @@
 #ifndef HEADLESS
 
 #define BIT_DEPTH_MULTI java_awt_DisplayMode_BIT_DEPTH_MULTI
+#define REFRESH_RATE_UNKNOWN java_awt_DisplayMode_REFRESH_RATE_UNKNOWN
 
 typedef Status
     (*XRRQueryVersionType) (Display *dpy, int *major_versionp, int *minor_versionp);
@@ -1765,6 +1766,7 @@
 {
     jclass displayModeClass;
     jmethodID cid;
+    jint validRefreshRate = refreshRate;
 
     displayModeClass = (*env)->FindClass(env, "java/awt/DisplayMode");
     if (JNU_IsNull(env, displayModeClass)) {
@@ -1780,8 +1782,13 @@
         return NULL;
     }
 
+    // early versions of xrandr may report "empty" rates (6880694)
+    if (validRefreshRate <= 0) {
+        validRefreshRate = REFRESH_RATE_UNKNOWN;
+    }
+
     return (*env)->NewObject(env, displayModeClass, cid,
-                             width, height, bitDepth, refreshRate);
+                             width, height, bitDepth, validRefreshRate);
 }
 
 static void
@@ -1926,8 +1933,7 @@
         curRate = awt_XRRConfigCurrentRate(config);
 
         if ((sizes != NULL) &&
-            (curSizeIndex < nsizes) &&
-            (curRate > 0))
+            (curSizeIndex < nsizes))
         {
             XRRScreenSize curSize = sizes[curSizeIndex];
             displayMode = X11GD_CreateDisplayMode(env,