X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/19b409860202ab9bdc27dab3d17f388c1a1d9717..289532452089421ddadbd4726a8469511a19ab76:/src/osx/cocoa/colour.mm

diff --git a/src/osx/cocoa/colour.mm b/src/osx/cocoa/colour.mm
index aebe52e1f3..a59b71b2c0 100644
--- a/src/osx/cocoa/colour.mm
+++ b/src/osx/cocoa/colour.mm
@@ -19,23 +19,28 @@
 
 #include "wx/osx/private.h"
 
-#if wxOSX_USE_COCOA
 wxColour::wxColour(WX_NSColor col)
 {
     size_t noComp = [col numberOfComponents];
-    
-    CGFloat *components = NULL;
-    if ( noComp >= 1 && noComp <= 4 )
+
+    CGFloat components[4];
+    CGFloat *p;
+    if ( noComp < 1 || noComp > WXSIZEOF(components) )
     {
         // TODO verify whether we really are on a RGB color space
         m_alpha = wxALPHA_OPAQUE;
         [col getComponents: components];
+        p = components;
+    }
+    else // Unsupported colour format.
+    {
+        p = NULL;
     }
-    InitFromComponents(const_cast<const CGFloat*>(components), noComp);
+
+    InitFromComponents(components, noComp);
 }
 
 WX_NSColor wxColour::OSXGetNSColor()
 {
-    return [NSColor colorWithDeviceRed:m_red / 255.0 green:m_green / 255.0 blue:m_blue / 255.0 alpha:m_alpha / 255.0]; 
+    return [NSColor colorWithDeviceRed:m_red / 255.0 green:m_green / 255.0 blue:m_blue / 255.0 alpha:m_alpha / 255.0];
 }
-#endif
\ No newline at end of file