QMdiArea: port Q_FOREACH to ranged-for, d->pendingRearrangements

Take a copy of the member container as the loop may modify the container
(either by moving/reordering the Rearranger elements or by appending).

Pick-to: 6.6 6.5
Task-number: QTBUG-115803
Change-Id: Iaf891b29e9c7cdfdb3dc82e03ed94defb8d0cf4c
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
This commit is contained in:
Ahmad Samir 2023-08-07 21:26:06 +03:00
parent 4ba7a76985
commit cfec14e1ff

View File

@ -2329,7 +2329,9 @@ void QMdiArea::showEvent(QShowEvent *showEvent)
Q_D(QMdiArea);
if (!d->pendingRearrangements.isEmpty()) {
bool skipPlacement = false;
foreach (Rearranger *rearranger, d->pendingRearrangements) {
// Take a copy because d->rearrange() may modify d->pendingRearrangements
const auto pendingRearrange = d->pendingRearrangements;
for (Rearranger *rearranger : pendingRearrange) {
// If this is the case, we don't have to lay out pending child windows
// since the rearranger will find a placement for them.
if (rearranger->type() != Rearranger::IconTiler && !skipPlacement)