diff options
Diffstat (limited to 'macosx/tkMacOSXColor.c')
-rw-r--r-- | macosx/tkMacOSXColor.c | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/macosx/tkMacOSXColor.c b/macosx/tkMacOSXColor.c index 39e443e..dde9df2 100644 --- a/macosx/tkMacOSXColor.c +++ b/macosx/tkMacOSXColor.c @@ -7,7 +7,7 @@ * * Copyright (c) 1990-1994 The Regents of the University of California. * Copyright (c) 1994-1996 Sun Microsystems, Inc. - * Copyright 2001-2009, Apple Inc. + * Copyright (c) 2001-2009 Apple Inc. * Copyright (c) 2006-2009 Daniel A. Steffen <das@users.sourceforge.net> * Copyright (c) 2020 Marc Culler * @@ -462,6 +462,8 @@ TkMacOSXInDarkMode(Tk_Window tkwin) } return (name == NSAppearanceNameDarkAqua); } +#else + (void) tkwin; #endif return false; } @@ -519,16 +521,19 @@ TkSetMacColor( NSColor* TkMacOSXGetNSColor( - GC gc, + TCL_UNUSED(GC), unsigned long pixel) /* Pixel value to convert. */ { - CGColorRef cgColor; + CGColorRef cgColor = NULL; NSColor *nsColor = nil; TkSetMacColor(pixel, &cgColor); - nsColor = [NSColor colorWithColorSpace:sRGB - components:CGColorGetComponents(cgColor) - count:CGColorGetNumberOfComponents(cgColor)]; + if (cgColor) { + nsColor = [NSColor colorWithColorSpace:sRGB + components:CGColorGetComponents(cgColor) + count:CGColorGetNumberOfComponents(cgColor)]; + CGColorRelease(cgColor); + } return nsColor; } @@ -552,12 +557,12 @@ TkMacOSXGetNSColor( void TkMacOSXSetColorInContext( - GC gc, + TCL_UNUSED(GC), unsigned long pixel, CGContextRef context) { OSStatus err = noErr; - CGColorRef cgColor = nil; + CGColorRef cgColor = NULL; SystemColorDatum *entry = GetEntryFromPixel(pixel); CGRect rect; HIThemeBackgroundDrawInfo info = {0, kThemeStateActive, 0}; @@ -653,7 +658,7 @@ TkpGetColor( if (hPtr != NULL) { SystemColorDatum *entry = (SystemColorDatum *)Tcl_GetHashValue(hPtr); - CGColorRef c; + CGColorRef c = NULL; p.pixel.colortype = entry->type; p.pixel.value = entry->index; @@ -674,7 +679,7 @@ TkpGetColor( colormap = lightColormap; } if (@available(macOS 11.0, *)) { - CGFloat *rgbaPtr = rgba; + CGFloat *rgbaPtr = rgba; [windowAppearance performAsCurrentDrawingAppearance:^{ GetRGBA(entry, p.ulong, rgbaPtr); }]; |