diff options
author | culler <culler> | 2019-04-12 15:49:41 (GMT) |
---|---|---|
committer | culler <culler> | 2019-04-12 15:49:41 (GMT) |
commit | 06eae3afe11df81ccf06822a9e6d186b657138ba (patch) | |
tree | 7dfc4d5f9252c48660b6c5df9fdabe94a1bc9f02 /macosx/tkMacOSXColor.c | |
parent | 68457210ab2ba459c2964532adf30c6dcfce13f8 (diff) | |
download | tk-06eae3afe11df81ccf06822a9e6d186b657138ba.zip tk-06eae3afe11df81ccf06822a9e6d186b657138ba.tar.gz tk-06eae3afe11df81ccf06822a9e6d186b657138ba.tar.bz2 |
Fix the build for OSX 10.6 (Snow Leopard).
Diffstat (limited to 'macosx/tkMacOSXColor.c')
-rw-r--r-- | macosx/tkMacOSXColor.c | 40 |
1 files changed, 24 insertions, 16 deletions
diff --git a/macosx/tkMacOSXColor.c b/macosx/tkMacOSXColor.c index 5e983e3..0a25490 100644 --- a/macosx/tkMacOSXColor.c +++ b/macosx/tkMacOSXColor.c @@ -257,6 +257,8 @@ GetEntryFromPixelCode( *---------------------------------------------------------------------- */ +static NSColorSpace* deviceRGB = NULL; + static OSStatus SetCGColorComponents( struct SystemColorMapEntry entry, @@ -266,11 +268,17 @@ SetCGColorComponents( OSStatus err = noErr; NSColor *bgColor, *color; CGFloat rgba[4] = {0, 0, 0, 1}; - static CGColorSpaceRef deviceRGBSpace = NULL; - if (!deviceRGBSpace) { - deviceRGBSpace = CGColorSpaceCreateDeviceRGB(); + if (!deviceRGB) { + deviceRGB = [NSColorSpace deviceRGBColorSpace]; } + /* + * This function is called before our autorelease pool is set up, + * so it needs its own pool. + */ + + NSAutoreleasePool *pool = [NSAutoreleasePool new]; + switch (entry.type) { case HIBrush: err = ChkErr(HIThemeBrushCreateCGColor, entry.value, c); @@ -282,7 +290,7 @@ SetCGColorComponents( break; case ttkBackground: bgColor = [[NSColor windowBackgroundColor] colorUsingColorSpace: - [NSColorSpace deviceRGBColorSpace]]; + deviceRGB]; [bgColor getComponents: rgba]; for (int i=0; i<3; i++) { rgba[i] -= entry.value*(8.0/255.0); @@ -292,45 +300,45 @@ SetCGColorComponents( switch (entry.value) { case 0: color = [[NSColor textColor] colorUsingColorSpace: - [NSColorSpace deviceRGBColorSpace]]; + deviceRGB]; break; case 1: color = [[NSColor selectedTextColor] colorUsingColorSpace: - [NSColorSpace deviceRGBColorSpace]]; + deviceRGB]; break; case 2: #if MAC_OS_X_VERSION_MIN_REQUIRED > 101000 color = [[NSColor labelColor] colorUsingColorSpace: - [NSColorSpace deviceRGBColorSpace]]; + deviceRGB]; #else color = [[NSColor textColor] colorUsingColorSpace: - [NSColorSpace deviceRGBColorSpace]]; + deviceRGB]; #endif break; case 3: color = [[NSColor controlTextColor] colorUsingColorSpace: - [NSColorSpace deviceRGBColorSpace]]; + deviceRGB]; break; case 4: color = [[NSColor disabledControlTextColor] colorUsingColorSpace: - [NSColorSpace deviceRGBColorSpace]]; + deviceRGB]; break; case 5: color = [[NSColor textBackgroundColor] colorUsingColorSpace: - [NSColorSpace deviceRGBColorSpace]]; + deviceRGB]; break; case 6: color = [[NSColor selectedTextBackgroundColor] colorUsingColorSpace: - [NSColorSpace deviceRGBColorSpace]]; + deviceRGB]; break; default: if ([NSApp macMinorVersion] < 10) { color = [[NSColor textColor] colorUsingColorSpace: - [NSColorSpace deviceRGBColorSpace]]; + deviceRGB]; } else { #if MAC_OS_X_VERSION_MIN_REQUIRED >= 101000 color = [[NSColor labelColor] colorUsingColorSpace: - [NSColorSpace deviceRGBColorSpace]]; + deviceRGB]; #endif break; } @@ -352,7 +360,8 @@ SetCGColorComponents( default: break; } - *c = CGColorCreate(deviceRGBSpace, rgba ); + *c = CGColorCreate(deviceRGB.CGColorSpace, rgba ); + [pool drain]; return err; } @@ -684,7 +693,6 @@ TkpGetColor( if (strncasecmp(name, "system", 6) == 0) { Tcl_Obj *strPtr = Tcl_NewStringObj(name+6, -1); int idx, result; - result = Tcl_GetIndexFromObjStruct(NULL, strPtr, systemColorMap, sizeof(struct SystemColorMapEntry), NULL, TCL_EXACT, &idx); Tcl_DecrRefCount(strPtr); |