Fix crash in wxColour ctor from NSColor in wxOSX/Cocoa.
wxColour ctor from NSColor added by Kevin Ollivier in r62525 never worked as it passed NULL pointer to NSColor:getComponents and so always crashed. This resulted in a crash in the rich text editor of the text sample, for example. Fix this by passing a valid array containing colour components instead. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@66030 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -23,14 +23,21 @@ 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;
|
||||
}
|
||||
InitFromComponents(const_cast<const CGFloat*>(components), noComp);
|
||||
else // Unsupported colour format.
|
||||
{
|
||||
p = NULL;
|
||||
}
|
||||
|
||||
InitFromComponents(components, noComp);
|
||||
}
|
||||
|
||||
WX_NSColor wxColour::OSXGetNSColor()
|
||||
|
Reference in New Issue
Block a user