7175566: [macosx] Glich in fix for CR7124247 caused MacOS crash during PIT testing
authorkizune
Fri, 08 Jun 2012 22:21:53 +0400
changeset 12840 4157f2200059
parent 12839 6bce0ca69176
child 12841 c5ca850e1dff
child 12999 d0cec5582bd7
7175566: [macosx] Glich in fix for CR7124247 caused MacOS crash during PIT testing Reviewed-by: anthony, dcherepanov
jdk/src/macosx/native/sun/awt/CGraphicsDevice.m
--- a/jdk/src/macosx/native/sun/awt/CGraphicsDevice.m	Fri Jun 08 14:15:09 2012 +0400
+++ b/jdk/src/macosx/native/sun/awt/CGraphicsDevice.m	Fri Jun 08 22:21:53 2012 +0400
@@ -92,8 +92,8 @@
     CFStringRef currentBPP = CGDisplayModeCopyPixelEncoding(mode);
     bpp = getBPPFromModeString(currentBPP);
     refrate = CGDisplayModeGetRefreshRate(mode);
-    h = CGDisplayPixelsHigh(displayID);
-    w = CGDisplayPixelsWide(displayID);
+    h = CGDisplayModeGetHeight(mode);
+    w = CGDisplayModeGetWidth(mode);
     CFRelease(currentBPP);
     static JNF_CLASS_CACHE(jc_DisplayMode, "java/awt/DisplayMode");
     static JNF_CTOR_CACHE(jc_DisplayMode_ctor, jc_DisplayMode, "(IIII)V");
@@ -154,13 +154,17 @@
     CFArrayRef allModes = CGDisplayCopyAllDisplayModes(displayID, NULL);
     CGDisplayModeRef closestMatch = getBestModeForParameters(allModes, (int)w, (int)h, (int)bpp, (int)refrate);
     if (closestMatch != NULL) {
-        CGDisplayConfigRef config;
-        CGError retCode = CGBeginDisplayConfiguration(&config);
-        if (retCode == kCGErrorSuccess) {
-            CGConfigureDisplayWithDisplayMode(config, displayID, closestMatch, NULL);
-            CGCompleteDisplayConfiguration(config, kCGConfigureForAppOnly);
-            CFRelease(config);
-        }
+        [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){
+            CGDisplayConfigRef config;
+            CGError retCode = CGBeginDisplayConfiguration(&config);
+            if (retCode == kCGErrorSuccess) {
+                CGConfigureDisplayWithDisplayMode(config, displayID, closestMatch, NULL);
+                CGCompleteDisplayConfiguration(config, kCGConfigureForAppOnly);
+                if (config != NULL) {
+                    CFRelease(config);
+                }
+            }
+        }];
     }
     CFRelease(allModes);
     JNF_COCOA_EXIT(env);