changeset 1899:7dd452521ab3

6880694: GraphicsDevice.setFullScreenWindow(null) throws NPE if there's a fullscreen window displayed Summary: handle "empty" refresh rates Reviewed-by: art, anthony
author dcherepanov
date Wed, 11 Nov 2009 19:18:27 +0300
parents 50321e4d46eb
children d0a17624ac54
files src/solaris/native/sun/awt/awt_GraphicsEnv.c
diffstat 1 files changed, 9 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/solaris/native/sun/awt/awt_GraphicsEnv.c	Wed Nov 11 17:46:58 2009 +0300
+++ b/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,