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>
This commit is contained in:
Sergio Martins 2018-01-12 18:03:27 +00:00 committed by Sérgio Martins
parent f40cc95d05
commit e459130e70

View File

@ -2692,26 +2692,21 @@ 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) {
for (const QObject *object : objects) {
if (auto widget = qobject_cast<QWidget*>(const_cast<QObject*>(object))) {
widget->style()->polish(widget);
QApplication::sendEvent(widget, &event);
}
}
}
/////////////////////////////////////////////////////////////////////////////////////////
// The stylesheet style