From 56d125041f8f9f1787cdf8fd47032fce759ac9a3 Mon Sep 17 00:00:00 2001 From: Stefan Csomor Date: Thu, 14 Jun 2018 20:11:26 +0200 Subject: [PATCH] Use built-in conversion to CGColorRef where available --- src/osx/cocoa/colour.mm | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/osx/cocoa/colour.mm b/src/osx/cocoa/colour.mm index aca75b9174..e6a4d1750a 100644 --- a/src/osx/cocoa/colour.mm +++ b/src/osx/cocoa/colour.mm @@ -21,6 +21,16 @@ static inline wxColour::ChannelType NSColorChannelToWX(CGFloat c) wxColour::wxColour(WX_NSColor col) { +#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_8 + if ( wxPlatformInfo::Get().CheckOSVersion(10, 8) ) + { + CGColorRef cgcolor = [col CGColor]; + CFRetain(cgcolor); + InitCGColorRef(cgcolor); + return ; + } +#endif + // Simplest case is when we can directly get the RGBA components: if ( NSColor* colRGBA = [col colorUsingColorSpaceName:NSCalibratedRGBColorSpace] ) {