From 9e8a7b0ff70abc96e05cbcfe5ad043cd75b3a251 Mon Sep 17 00:00:00 2001 From: kizune Date: Fri, 8 Jun 2012 22:21:53 +0400 Subject: [PATCH] 7175566: [macosx] Glich in fix for CR7124247 caused MacOS crash during PIT testing Reviewed-by: anthony, dcherepanov --- src/macosx/native/sun/awt/CGraphicsDevice.m | 22 ++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/macosx/native/sun/awt/CGraphicsDevice.m b/src/macosx/native/sun/awt/CGraphicsDevice.m index f24a86283..62034c825 100644 --- a/src/macosx/native/sun/awt/CGraphicsDevice.m +++ b/src/macosx/native/sun/awt/CGraphicsDevice.m @@ -92,8 +92,8 @@ static jobject createJavaDisplayMode(CGDisplayModeRef mode, JNIEnv *env, jint di 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 @@ Java_sun_awt_CGraphicsDevice_nativeSetDisplayMode 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); -- GitLab