From 35b871b2b67815a320e48c6beef45ce01326f097 Mon Sep 17 00:00:00 2001 From: David Faure Date: Tue, 23 Aug 2016 22:34:21 +0200 Subject: [PATCH] QStyleSheetStyle: don't call pixelMetric when not needed fixupBorder does nothing when bd is null, i.e. hasBorder() returns false. Change-Id: Ic88e3a793f32bd4ad25830ddad9dbd8100348279 Reviewed-by: Friedemann Kleint Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/widgets/styles/qstylesheetstyle.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp index cb3c2a410b..568a4755e4 100644 --- a/src/widgets/styles/qstylesheetstyle.cpp +++ b/src/widgets/styles/qstylesheetstyle.cpp @@ -996,15 +996,17 @@ QRenderRule::QRenderRule(const QVector &declarations, const QObject } } - if (const QWidget *widget = qobject_cast(object)) { - QStyleSheetStyle *style = const_cast(globalStyleSheetStyle); - if (!style) - style = qobject_cast(widget->style()); - if (style) - fixupBorder(style->nativeFrameWidth(widget)); + if (hasBorder()) { + if (const QWidget *widget = qobject_cast(object)) { + QStyleSheetStyle *style = const_cast(globalStyleSheetStyle); + if (!style) + style = qobject_cast(widget->style()); + if (style) + fixupBorder(style->nativeFrameWidth(widget)); + } + if (border()->hasBorderImage()) + defaultBackground = QBrush(); } - if (hasBorder() && border()->hasBorderImage()) - defaultBackground = QBrush(); } QRect QRenderRule::borderRect(const QRect& r) const