jdk/src/macosx/native/sun/awt/CGraphicsDevice.m
changeset 13241 92c2140b5bb2
parent 12840 4157f2200059
child 15989 0fe0985a7bde
--- a/jdk/src/macosx/native/sun/awt/CGraphicsDevice.m	Tue Jul 17 12:59:57 2012 +0400
+++ b/jdk/src/macosx/native/sun/awt/CGraphicsDevice.m	Wed Jul 18 18:25:49 2012 +0400
@@ -28,7 +28,7 @@
 /*
  * Convert the mode string to the more convinient bits per pixel value
  */
-static int getBPPFromModeString(CFStringRef mode) 
+static int getBPPFromModeString(CFStringRef mode)
 {
     if ((CFStringCompare(mode, CFSTR(kIO30BitDirectPixels), kCFCompareCaseInsensitive) == kCFCompareEqualTo)) {
         // This is a strange mode, where we using 10 bits per RGB component and pack it into 32 bits
@@ -44,7 +44,7 @@
     else if (CFStringCompare(mode, CFSTR(IO8BitIndexedPixels), kCFCompareCaseInsensitive) == kCFCompareEqualTo) {
         return 8;
     }
-    
+
     return 0;
 }
 
@@ -68,6 +68,11 @@
             // One of the key parameters does not match
             continue;
         }
+
+        if (refrate == 0) { // REFRESH_RATE_UNKNOWN
+            return cRef;
+        }
+
         // Refresh rate might be 0 in display mode and we ask for specific display rate
         // but if we do not find exact match then 0 refresh rate might be just Ok
         if (CGDisplayModeGetRefreshRate(cRef) == refrate) {
@@ -165,7 +170,10 @@
                 }
             }
         }];
+    } else {
+        [JNFException raise:env as:kIllegalArgumentException reason:"Invalid display mode"];
     }
+
     CFRelease(allModes);
     JNF_COCOA_EXIT(env);
 }