diff options
author | culler <culler> | 2020-11-09 13:32:29 (GMT) |
---|---|---|
committer | culler <culler> | 2020-11-09 13:32:29 (GMT) |
commit | e1bfe977169f9b112ee0a0093eafa78f788629b5 (patch) | |
tree | aaf532a3d66125c185ad747691f7d2b66b3f9fa0 /macosx/tkMacOSXColor.c | |
parent | 0fc4b2a839f32fc8819246d1c29451f258ee3a8d (diff) | |
download | tk-e1bfe977169f9b112ee0a0093eafa78f788629b5.zip tk-e1bfe977169f9b112ee0a0093eafa78f788629b5.tar.gz tk-e1bfe977169f9b112ee0a0093eafa78f788629b5.tar.bz2 |
Fix [f9fa926666] on macOS only: crash when creating a label whose text is a single emoji.
Diffstat (limited to 'macosx/tkMacOSXColor.c')
-rw-r--r-- | macosx/tkMacOSXColor.c | 94 |
1 files changed, 3 insertions, 91 deletions
diff --git a/macosx/tkMacOSXColor.c b/macosx/tkMacOSXColor.c index 5f549b1..d3c76e5 100644 --- a/macosx/tkMacOSXColor.c +++ b/macosx/tkMacOSXColor.c @@ -485,89 +485,6 @@ TkSetMacColor( /* *---------------------------------------------------------------------- * - * TkpInitGCCache, TkpFreeGCCache, CopyCachedColor, SetCachedColor -- - * - * Maintain a per-GC cache of previously converted CGColorRefs - * - * Results: - * None resp. retained CGColorRef for CopyCachedColor() - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -void -TkpInitGCCache( - GC gc) -{ - bzero(TkpGetGCCache(gc), sizeof(TkpGCCache)); -} - -void -TkpFreeGCCache( - GC gc) -{ - TkpGCCache *gcCache = TkpGetGCCache(gc); - - if (gcCache->cachedForegroundColor) { - CFRelease(gcCache->cachedForegroundColor); - } - if (gcCache->cachedBackgroundColor) { - CFRelease(gcCache->cachedBackgroundColor); - } -} - -static CGColorRef -CopyCachedColor( - GC gc, - unsigned long pixel) -{ - TkpGCCache *gcCache = TkpGetGCCache(gc); - CGColorRef cgColor = NULL; - - if (gcCache) { - if (gcCache->cachedForeground == pixel) { - cgColor = gcCache->cachedForegroundColor; - } else if (gcCache->cachedBackground == pixel) { - cgColor = gcCache->cachedBackgroundColor; - } - if (cgColor) { - CFRetain(cgColor); - } - } - return cgColor; -} - -static void -SetCachedColor( - GC gc, - unsigned long pixel, - CGColorRef cgColor) -{ - TkpGCCache *gcCache = TkpGetGCCache(gc); - - if (gcCache && cgColor) { - if (gc->foreground == pixel) { - if (gcCache->cachedForegroundColor) { - CFRelease(gcCache->cachedForegroundColor); - } - gcCache->cachedForegroundColor = (CGColorRef) CFRetain(cgColor); - gcCache->cachedForeground = pixel; - } else if (gc->background == pixel) { - if (gcCache->cachedBackgroundColor) { - CFRelease(gcCache->cachedBackgroundColor); - } - gcCache->cachedBackgroundColor = (CGColorRef) CFRetain(cgColor); - gcCache->cachedBackground = pixel; - } - } -} - -/* - *---------------------------------------------------------------------- - * * TkMacOSXCreateCGColor -- * * Creates a CGColorRef from a X style pixel value. @@ -586,11 +503,8 @@ TkMacOSXCreateCGColor( GC gc, unsigned long pixel) /* Pixel value to convert. */ { - CGColorRef cgColor = CopyCachedColor(gc, pixel); - - if (!cgColor && TkSetMacColor(pixel, &cgColor)) { - SetCachedColor(gc, pixel, cgColor); - } + CGColorRef cgColor; + TkSetMacColor(pixel, &cgColor); return cgColor; } @@ -683,9 +597,7 @@ TkMacOSXSetColorInContext( context, kHIThemeOrientationNormal); break; default: - if (SetCGColorComponents(entry, pixel, &cgColor)){ - SetCachedColor(gc, pixel, cgColor); - } + SetCGColorComponents(entry, pixel, &cgColor); break; } } |