QMdiArea: port Q_FOREACH to ranged-for: loop doesn't change container

The container is childWindows in all cases:
- place(): queries the windows' geometries
- setChildActivationEnabled(): sets a bool member in subwindow->d
- subWindowList(): {pre,ap}pends windows pointers to a separate QList

Pick-to: 6.6 6.5
Task-number: QTBUG-115803
Change-Id: I0fdd5f22f29f085b71bf46f68bf9ec04c45c9317
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
This commit is contained in:
Ahmad Samir 2023-08-10 01:41:15 +03:00
parent 446af298b0
commit 79dc2980e6

View File

@ -848,7 +848,7 @@ void QMdiAreaPrivate::place(Placer *placer, QMdiSubWindow *child)
QList<QRect> rects;
rects.reserve(childWindows.size());
QRect parentRect = q->rect();
foreach (QMdiSubWindow *window, childWindows) {
for (QMdiSubWindow *window : std::as_const(childWindows)) {
if (!sanityCheck(window, "QMdiArea::place") || window == child || !window->isVisibleTo(q)
|| !window->testAttribute(Qt::WA_Moved)) {
continue;
@ -1304,7 +1304,7 @@ bool QMdiAreaPrivate::lastWindowAboutToBeDestroyed() const
*/
void QMdiAreaPrivate::setChildActivationEnabled(bool enable, bool onlyNextActivationEvent) const
{
foreach (QMdiSubWindow *subWindow, childWindows) {
for (QMdiSubWindow *subWindow : childWindows) {
if (!subWindow || !subWindow->isVisible())
continue;
if (onlyNextActivationEvent)
@ -1342,7 +1342,7 @@ QMdiAreaPrivate::subWindowList(QMdiArea::WindowOrder order, bool reversed) const
return list;
if (order == QMdiArea::CreationOrder) {
foreach (QMdiSubWindow *child, childWindows) {
for (QMdiSubWindow *child : childWindows) {
if (!child)
continue;
if (!reversed)