[mac] LayoutTestHelper crashes if there is no main display
authortimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 2 Apr 2012 21:23:38 +0000 (21:23 +0000)
committertimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 2 Apr 2012 21:23:38 +0000 (21:23 +0000)
https://bugs.webkit.org/show_bug.cgi?id=82944
<rdar://problem/11162954>

Reviewed by Simon Fraser.

If there's no main display attached, ColorSyncDeviceCopyDeviceInfo returns
a null dictionary, so we shouldn't go ahead and try to read from it.

* DumpRenderTree/mac/LayoutTestHelper.m:
(installLayoutTestColorProfile):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@112943 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Tools/ChangeLog
Tools/DumpRenderTree/mac/LayoutTestHelper.m

index 7aa4a69..c84abbf 100644 (file)
@@ -1,3 +1,17 @@
+2012-04-02  Tim Horton  <timothy_horton@apple.com>
+
+        [mac] LayoutTestHelper crashes if there is no main display
+        https://bugs.webkit.org/show_bug.cgi?id=82944
+        <rdar://problem/11162954>
+
+        Reviewed by Simon Fraser.
+
+        If there's no main display attached, ColorSyncDeviceCopyDeviceInfo returns
+        a null dictionary, so we shouldn't go ahead and try to read from it.
+
+        * DumpRenderTree/mac/LayoutTestHelper.m:
+        (installLayoutTestColorProfile):
+
 2012-04-02  Balazs Kelemen  <kbalazs@webkit.org>
 
         [Qt][WK2] Set up plugin process on Unix
index a277a63..937a5c7 100644 (file)
@@ -54,6 +54,13 @@ static void installLayoutTestColorProfile()
     
     if (!sUserColorProfileURL) {
         CFDictionaryRef deviceInfo = ColorSyncDeviceCopyDeviceInfo(kColorSyncDisplayDeviceClass, mainDisplayID);
+
+        if (!deviceInfo) {
+            NSLog(@"No display attached to system; not setting main display's color profile.");
+            CFRelease(mainDisplayID);
+            return;
+        }
+
         CFDictionaryRef profileInfo = (CFDictionaryRef)CFDictionaryGetValue(deviceInfo, kColorSyncCustomProfiles);
         if (profileInfo) {
             sUserColorProfileURL = (CFURLRef)CFDictionaryGetValue(profileInfo, CFSTR("1"));
@@ -83,7 +90,7 @@ static void installLayoutTestColorProfile()
     CFDictionarySetValue(profileInfo, kColorSyncDeviceDefaultProfileID, profileURL);
     
     if (!ColorSyncDeviceSetCustomProfiles(kColorSyncDisplayDeviceClass, mainDisplayID, profileInfo)) {
-        fprintf(stderr, "Failed to set color profile for main display! Many pixel tests may fail as a result.\n");
+        NSLog(@"Failed to set color profile for main display! Many pixel tests may fail as a result.");
         
         if (sUserColorProfileURL) {
             CFRelease(sUserColorProfileURL);