Add M_COLDATA access asserts to wxOSX
Similarly to wxGTK, check the color for validity before deferencing its ref data.
This commit is contained in:
committed by
Václav Slavík
parent
d3e35b6bb1
commit
7564d7ff27
@@ -163,27 +163,37 @@ wxColour::wxColour(CGColorRef col)
|
|||||||
|
|
||||||
wxColour::ChannelType wxColour::Red() const
|
wxColour::ChannelType wxColour::Red() const
|
||||||
{
|
{
|
||||||
|
wxCHECK_MSG( IsOk(), 0, "invalid colour" );
|
||||||
|
|
||||||
return wxRound(M_COLDATA->Red() * 255.0);
|
return wxRound(M_COLDATA->Red() * 255.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
wxColour::ChannelType wxColour::Green() const
|
wxColour::ChannelType wxColour::Green() const
|
||||||
{
|
{
|
||||||
|
wxCHECK_MSG( IsOk(), 0, "invalid colour" );
|
||||||
|
|
||||||
return wxRound(M_COLDATA->Green() * 255.0);
|
return wxRound(M_COLDATA->Green() * 255.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
wxColour::ChannelType wxColour::Blue() const
|
wxColour::ChannelType wxColour::Blue() const
|
||||||
{
|
{
|
||||||
|
wxCHECK_MSG( IsOk(), 0, "invalid colour" );
|
||||||
|
|
||||||
return wxRound(M_COLDATA->Blue() * 255.0);
|
return wxRound(M_COLDATA->Blue() * 255.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
wxColour::ChannelType wxColour::Alpha() const
|
wxColour::ChannelType wxColour::Alpha() const
|
||||||
{
|
{
|
||||||
|
wxCHECK_MSG( IsOk(), 0, "invalid colour" );
|
||||||
|
|
||||||
return wxRound(M_COLDATA->Alpha() * 255.0);
|
return wxRound(M_COLDATA->Alpha() * 255.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if wxOSX_USE_COCOA_OR_CARBON
|
#if wxOSX_USE_COCOA_OR_CARBON
|
||||||
void wxColour::GetRGBColor(RGBColor* col) const
|
void wxColour::GetRGBColor(RGBColor* col) const
|
||||||
{
|
{
|
||||||
|
wxCHECK_RET( IsOk(), "invalid colour" );
|
||||||
|
|
||||||
col->red = M_COLDATA->Red() * 65535.0;
|
col->red = M_COLDATA->Red() * 65535.0;
|
||||||
col->blue = M_COLDATA->Blue() * 65535.0;
|
col->blue = M_COLDATA->Blue() * 65535.0;
|
||||||
col->green = M_COLDATA->Green() * 65535.0;
|
col->green = M_COLDATA->Green() * 65535.0;
|
||||||
@@ -192,12 +202,16 @@ void wxColour::GetRGBColor(RGBColor* col) const
|
|||||||
|
|
||||||
CGColorRef wxColour::GetCGColor() const
|
CGColorRef wxColour::GetCGColor() const
|
||||||
{
|
{
|
||||||
|
wxCHECK_MSG( IsOk(), NULL, "invalid colour" );
|
||||||
|
|
||||||
return M_COLDATA->GetCGColor();
|
return M_COLDATA->GetCGColor();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if wxOSX_USE_COCOA
|
#if wxOSX_USE_COCOA
|
||||||
WX_NSColor wxColour::OSXGetNSColor() const
|
WX_NSColor wxColour::OSXGetNSColor() const
|
||||||
{
|
{
|
||||||
|
wxCHECK_MSG( IsOk(), NULL, "invalid colour" );
|
||||||
|
|
||||||
return M_COLDATA->GetNSColor();
|
return M_COLDATA->GetNSColor();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user