diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2015-11-30 11:03:29 +0100 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@theqtcompany.com> | 2015-12-07 13:41:17 +0000 |
commit | bc6d677b7e9c7809af68d8bcbd3a5793903c4c98 (patch) | |
tree | 4caa4d182a62975b0e10c996dc72419d3337285e /src/widgets/kernel | |
parent | 1264c22b8670a0d999ab5f7983407838e3766126 (diff) |
QApplication: replace some sneaky code with a strategic goto
Instead of replacing the container iterated over, in the middle
of the loop body(!), place a label in front of the loop and
use goto to restart the entire loop.
This allows to mark the variable 'list' const, which is a
prerequesite for replacing the loop with a C++11 range-for
one.
But it also makes the code less cryptic. No-one expects the
container to be re-seated in the middle of the loop.
The compiler agrees: saves 144b of text size on optimized
AMD64 GCC 4.9 Linux builds.
Change-Id: I22d07672a1bbe9d7ffb083ae231eda760c29d350
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Diffstat (limited to 'src/widgets/kernel')
-rw-r--r-- | src/widgets/kernel/qapplication.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index 6fffe33ce8..4510fc85b6 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -1905,6 +1905,7 @@ bool QApplicationPrivate::tryCloseAllWidgetWindows(QWindowList *processedWindows processedWindows->append(window); } +retry: QWidgetList list = QApplication::topLevelWidgets(); for (int i = 0; i < list.size(); ++i) { QWidget *w = list.at(i); @@ -1915,8 +1916,7 @@ bool QApplicationPrivate::tryCloseAllWidgetWindows(QWindowList *processedWindows return false; if (window) processedWindows->append(window); - list = QApplication::topLevelWidgets(); - i = -1; + goto retry; } } return true; |