summaryrefslogtreecommitdiffstats
path: root/src/widgets/widgets
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2016-01-26 14:38:54 +0100
committerMarc Mutz <marc.mutz@kdab.com>2016-02-28 10:50:18 +0000
commit85c2a128ef8d1b5fbddf551691bccc0770e558ba (patch)
tree99580041fa8c0e60d2e91451d1a7531055803d3d /src/widgets/widgets
parente1c2bfa53b7549a1283f5b52974ea90b6a2b4659 (diff)
QtWidgets: eradicate Q_FOREACH loops [rvalues]
... by replacing them with C++11 range-for loops. This is the simplest of the patch series: Q_FOREACH took a copy, so we do, too. Except we don't, since we're just catching the return value that comes out of the function (RVO). We can't feed the rvalues into range-for, because they are non-const and would thus detach. Saves 2.2KiB in test size on optimized GCC 5.3 Linux AMD64 builds. Change-Id: I914aa20fe65577b2e32ea7ea89d51a8d003a57ba Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Diffstat (limited to 'src/widgets/widgets')
-rw-r--r--src/widgets/widgets/qdialogbuttonbox.cpp3
-rw-r--r--src/widgets/widgets/qmenu.cpp7
2 files changed, 7 insertions, 3 deletions
diff --git a/src/widgets/widgets/qdialogbuttonbox.cpp b/src/widgets/widgets/qdialogbuttonbox.cpp
index 6fc8cb5e26..2b68c308ec 100644
--- a/src/widgets/widgets/qdialogbuttonbox.cpp
+++ b/src/widgets/widgets/qdialogbuttonbox.cpp
@@ -964,7 +964,8 @@ bool QDialogButtonBox::event(QEvent *event)
break;
}
- foreach (QPushButton *pb, (dialog ? dialog : this)->findChildren<QPushButton *>()) {
+ const auto pbs = (dialog ? dialog : this)->findChildren<QPushButton *>();
+ for (QPushButton *pb : pbs) {
if (pb->isDefault() && pb != firstAcceptButton) {
hasDefault = true;
break;
diff --git a/src/widgets/widgets/qmenu.cpp b/src/widgets/widgets/qmenu.cpp
index c07d48a513..1b9e31968a 100644
--- a/src/widgets/widgets/qmenu.cpp
+++ b/src/widgets/widgets/qmenu.cpp
@@ -1270,14 +1270,17 @@ void QMenuPrivate::_q_platformMenuAboutToShow()
Q_Q(QMenu);
#ifdef Q_OS_OSX
- if (platformMenu)
- Q_FOREACH (QAction *action, q->actions())
+ if (platformMenu) {
+ const auto actions = q->actions();
+ for (QAction *action : actions) {
if (QWidget *widget = widgetItems.value(action))
if (widget->parent() == q) {
QPlatformMenuItem *menuItem = platformMenu->menuItemForTag(reinterpret_cast<quintptr>(action));
moveWidgetToPlatformItem(widget, menuItem);
platformMenu->syncMenuItem(menuItem);
}
+ }
+ }
#endif
emit q->aboutToShow();