From 50ba73cbf4cc7174ea64c589d7fa5552b4c70d4c Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 15 Dec 2019 18:41:02 +0100 Subject: [PATCH] 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 540fed921647308e952ec56d4624d2ebd09ea07a, see https://github.com/wxWidgets/wxWidgets/pull/1673 --- src/osx/cocoa/dataview.mm | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/osx/cocoa/dataview.mm b/src/osx/cocoa/dataview.mm index 1fe19e0c82..86c6b0468b 100644 --- a/src/osx/cocoa/dataview.mm +++ b/src/osx/cocoa/dataview.mm @@ -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];