Fix using unknown selector in Mac wxDataViewCtrl code

Don't call -[NSCell setTextColor:] unless it really handles it: testing
for "colText" validity was insufficient, as it could be set as a
fallback.

Also move the fallback assignments inside the branches where they're
really used.

This fixes a bug introduced in 540fed9216,
see https://github.com/wxWidgets/wxWidgets/pull/1673
This commit is contained in:
Vadim Zeitlin
2019-12-15 18:41:02 +01:00
parent f3217573d7
commit 50ba73cbf4

View File

@@ -2932,19 +2932,22 @@ void wxDataViewRenderer::SetAttr(const wxDataViewItemAttr& attr)
if ( !font )
font = data->GetOriginalFont();
if ( !colText )
colText = data->GetOriginalTextColour();
if ( !colBack )
colBack = data->GetOriginalBackgroundColour();
if ( font )
[cell setFont:font];
if ( colText )
if ( [cell respondsToSelector:@selector(setTextColor:)] )
{
if ( !colText )
colText = data->GetOriginalTextColour();
[(id)cell setTextColor:colText];
}
if ( [cell respondsToSelector:@selector(setDrawsBackground:)] )
{
if ( !colBack )
colBack = data->GetOriginalBackgroundColour();
if ( colBack )
{
[(id)cell setDrawsBackground:true];