From bb7bc4a05ef219238839d03259f6da7543377e0a Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Wed, 16 Dec 2015 14:25:21 +0100 Subject: [PATCH] QApplication: replace QList::prepend()s with appends() Use the new reverse_iterator support in QList to avoid building a QList with prepend()ing, using append() instead. Change-Id: I6b9d9b1a9941cf2e6cc39ad2d9097fdc629c24bc Reviewed-by: Friedemann Kleint --- src/widgets/kernel/qapplication.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index ab8c251f502..a843fdeda54 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -2330,7 +2330,7 @@ void QApplicationPrivate::dispatchEnterLeave(QWidget* enter, QWidget* leave, con if (enter && !sameWindow) { auto *w = enter; do { - enterList.prepend(w); + enterList.append(w); } while (!w->isWindow() && (w = w->parentWidget())); } if (sameWindow) { @@ -2361,7 +2361,7 @@ void QApplicationPrivate::dispatchEnterLeave(QWidget* enter, QWidget* leave, con leaveList.append(w); for (auto *w = enter; w != wenter; w = w->parentWidget()) - enterList.prepend(w); + enterList.append(w); } QEvent leaveEvent(QEvent::Leave); @@ -2383,9 +2383,9 @@ void QApplicationPrivate::dispatchEnterLeave(QWidget* enter, QWidget* leave, con const QPoint globalPos = qIsInf(globalPosF.x()) ? QPoint(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX) : globalPosF.toPoint(); - const QPoint windowPos = enterList.front()->window()->mapFromGlobal(globalPos); - for (int i = 0; i < enterList.size(); ++i) { - auto *w = enterList.at(i); + const QPoint windowPos = enterList.back()->window()->mapFromGlobal(globalPos); + for (auto it = enterList.crbegin(), end = enterList.crend(); it != end; ++it) { + auto *w = *it; if (!QApplication::activeModalWidget() || QApplicationPrivate::tryModalHelper(w, 0)) { const QPointF localPos = w->mapFromGlobal(globalPos); QEnterEvent enterEvent(localPos, windowPos, globalPosF);