From 4a6df5ec953018513b5b2c6724ba79b928d9260d Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Wed, 28 May 2014 09:09:57 +0200 Subject: [PATCH] Mac Style: Don't crash when rendering PE_IndicatorBranch without widget Change-Id: I45784af3738807ab6753b67a5b103a65d4e28084 Reviewed-by: Jake Petroules --- src/widgets/styles/qmacstyle_mac.mm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/widgets/styles/qmacstyle_mac.mm b/src/widgets/styles/qmacstyle_mac.mm index 36c7fbd0a0..da6422ffec 100644 --- a/src/widgets/styles/qmacstyle_mac.mm +++ b/src/widgets/styles/qmacstyle_mac.mm @@ -3148,7 +3148,8 @@ void QMacStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPai [triangleCell setButtonType:NSOnOffButton]; [triangleCell setState:(opt->state & State_Open) ? NSOnState : NSOffState]; [triangleCell setBezelStyle:NSDisclosureBezelStyle]; - [triangleCell setBackgroundStyle:((opt->state & State_Selected) && w->hasFocus()) ? NSBackgroundStyleDark : NSBackgroundStyleLight]; + bool viewHasFocus = (w && w->hasFocus()) || (opt->state & State_HasFocus); + [triangleCell setBackgroundStyle:((opt->state & State_Selected) && viewHasFocus) ? NSBackgroundStyleDark : NSBackgroundStyleLight]; CGContextSaveGState(cg); [NSGraphicsContext saveGraphicsState];