diff options
author | Sergio Martins <sergio.martins@kdab.com> | 2018-01-12 18:03:27 +0000 |
---|---|---|
committer | Sérgio Martins <sergio.martins@kdab.com> | 2018-01-13 12:21:02 +0000 |
commit | e459130e70b7c60ad3a768b09a581999458906e0 (patch) | |
tree | 43e57c620619f419076996cf9594e07fe046dff7 /src/widgets | |
parent | f40cc95d057dd59c8b0442caa7359b1ef4ca4429 (diff) |
qstylesheet: remove a few unneeded memory allocations
One foreach too many, creating a temporary container.
Converted to range-loop, as drive-by change.
Change-Id: Ie2bb94a7147edcfc0d8b5f479604f5ebe113d7cb
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Diffstat (limited to 'src/widgets')
-rw-r--r-- | src/widgets/styles/qstylesheetstyle.cpp | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp index 25ee085f30..7c553a9e1c 100644 --- a/src/widgets/styles/qstylesheetstyle.cpp +++ b/src/widgets/styles/qstylesheetstyle.cpp @@ -2692,24 +2692,19 @@ void QStyleSheetStyle::unsetStyleSheetFont(QWidget *w) const static void updateObjects(const QList<const QObject *>& objects) { if (!styleSheetCaches->styleRulesCache.isEmpty() || !styleSheetCaches->hasStyleRuleCache.isEmpty() || !styleSheetCaches->renderRulesCache.isEmpty()) { - for (int i = 0; i < objects.size(); ++i) { - const QObject *object = objects.at(i); + for (const QObject *object : objects) { styleSheetCaches->styleRulesCache.remove(object); styleSheetCaches->hasStyleRuleCache.remove(object); styleSheetCaches->renderRulesCache.remove(object); } } - QWidgetList widgets; - foreach (const QObject *object, objects) { - if (QWidget *w = qobject_cast<QWidget*>(const_cast<QObject*>(object))) - widgets << w; - } - QEvent event(QEvent::StyleChange); - foreach (QWidget *widget, widgets) { - widget->style()->polish(widget); - QApplication::sendEvent(widget, &event); + for (const QObject *object : objects) { + if (auto widget = qobject_cast<QWidget*>(const_cast<QObject*>(object))) { + widget->style()->polish(widget); + QApplication::sendEvent(widget, &event); + } } } |