From 3fe7f1de0362a38b36edae2a831cec450089d202 Mon Sep 17 00:00:00 2001 From: Damiano Galassi Date: Wed, 5 Oct 2016 10:55:45 +0200 Subject: MacGui: fix a small memory leak in the NSColor -> CGColor conversion. --- macosx/HBToolbarBadgedItem.m | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/macosx/HBToolbarBadgedItem.m b/macosx/HBToolbarBadgedItem.m index 135174701..e1eec2066 100644 --- a/macosx/HBToolbarBadgedItem.m +++ b/macosx/HBToolbarBadgedItem.m @@ -85,7 +85,7 @@ #pragma mark -- Private Methods -- (CGColorRef)HB_NSColorToCGColor:(NSColor *)color +- (CGColorRef)copyNSColorToCGColor:(NSColor *)color { // CGColor property of NSColor has been added only in 10.8, // we need to support 10.7 too. @@ -178,7 +178,9 @@ CGContextAddArcToPoint(context, maxx, maxy, midx, maxy, radius); CGContextAddArcToPoint(context, minx, maxy, minx, midy, radius); CGContextClosePath(context); - CGContextSetFillColorWithColor(context, [self HB_NSColorToCGColor:_badgeFillColor]); + CGColorRef fillColor = [self copyNSColorToCGColor:_badgeFillColor]; + CGContextSetFillColorWithColor(context,fillColor); + CFRelease(fillColor); CGContextDrawPath(context, kCGPathFill); // Draw the text -- cgit v1.2.3