Fix wxColour(NSColor) ctor and use it in wxOSX code
wxColour ctor from NSColor added inb478f24288
didn't work correctly as it didn't initialize wxColour::m_cgColour and so any attempts to use the colour created by it resulted in an immediate crash (so the code added in16671f229a
likely didn't work neither). It also assumed that the NSColor given to it was always in the RGBA colorspace and crashed if it wasn't (so56ebe6dfac
fixed compilation at the price of making the code crash at run-time). Now explicitly request the RGBA colorspace and leave the colour uninitialized, which is better than crashing, if it can't be obtained. After making this ctor safe to use, there is no reason to reproduce its logic in wxColourDialog and wxFontDialog, so just use it from there. Also make the ctor explicit as it's a non-trivial operation which shouldn't be performed implicitly and document that it doesn't take ownership of NSColor, unlike the similar ctor from CGColorRef.
This commit is contained in:
@@ -58,7 +58,8 @@ public:
|
||||
wxColour& operator=(const RGBColor& col);
|
||||
#endif
|
||||
#if wxOSX_USE_COCOA
|
||||
wxColour(WX_NSColor color);
|
||||
// This ctor does not take ownership of the color.
|
||||
explicit wxColour(WX_NSColor color);
|
||||
WX_NSColor OSXGetNSColor() const;
|
||||
#endif
|
||||
wxColour& operator=(CGColorRef col);
|
||||
|
Reference in New Issue
Block a user