diff --git a/src/composite.cpp b/src/composite.cpp index 283efc8473..618d3e7677 100644 --- a/src/composite.cpp +++ b/src/composite.cpp @@ -455,10 +455,12 @@ void Compositor::stop() } if (waylandServer()) { - for (AbstractClient *c : waylandServer()->clients()) { + const QList toRemoveTopLevel = waylandServer()->clients(); + for (AbstractClient *c : toRemoveTopLevel) { m_scene->removeToplevel(c); } - for (AbstractClient *c : waylandServer()->clients()) { + const QList toFinishCompositing = waylandServer()->clients(); + for (AbstractClient *c : toFinishCompositing) { c->finishCompositing(); } } @@ -591,7 +593,8 @@ void Compositor::composite(RenderLoop *renderLoop) QList windows = Workspace::self()->xStackingOrder(); // Move elevated windows to the top of the stacking order - for (EffectWindow *c : static_cast(effects)->elevatedWindows()) { + const QList elevatedList = static_cast(effects)->elevatedWindows(); + for (EffectWindow *c : elevatedList) { Toplevel *t = static_cast(c)->window(); windows.removeAll(t); windows.append(t); diff --git a/src/dbusinterface.cpp b/src/dbusinterface.cpp index bc0fe8a631..2884435b6d 100644 --- a/src/dbusinterface.cpp +++ b/src/dbusinterface.cpp @@ -387,7 +387,8 @@ VirtualDesktopManagerDBusInterface::VirtualDesktopManagerDBusInterface(VirtualDe connect(m_manager, &VirtualDesktopManager::rowsChanged, this, &VirtualDesktopManagerDBusInterface::rowsChanged); - for (auto *vd : m_manager->desktops()) { + const QVector allDesks = m_manager->desktops(); + for (auto *vd : allDesks) { connect(vd, &VirtualDesktop::x11DesktopNumberChanged, this, [this, vd]() { DBusDesktopDataStruct data{.position = vd->x11DesktopNumber() - 1, .id = vd->id(), .name = vd->name()}; diff --git a/src/effects/backgroundcontrast/contrast.cpp b/src/effects/backgroundcontrast/contrast.cpp index e9648f7c5e..c5f9c37045 100644 --- a/src/effects/backgroundcontrast/contrast.cpp +++ b/src/effects/backgroundcontrast/contrast.cpp @@ -52,7 +52,8 @@ ContrastEffect::ContrastEffect() ); // Fetch the contrast regions for all windows - for (EffectWindow *window: effects->stackingOrder()) { + const EffectWindowList windowList = effects->stackingOrder(); + for (EffectWindow *window : windowList) { updateContrastRegion(window); } } @@ -69,7 +70,9 @@ void ContrastEffect::slotScreenGeometryChanged() effects->reloadEffect(this); return; } - for (EffectWindow *window: effects->stackingOrder()) { + + const EffectWindowList windowList = effects->stackingOrder(); + for (EffectWindow *window : windowList) { updateContrastRegion(window); } } diff --git a/src/effects/desktopgrid/desktopgrid.cpp b/src/effects/desktopgrid/desktopgrid.cpp index 1793c47c40..d66abbc1bb 100644 --- a/src/effects/desktopgrid/desktopgrid.cpp +++ b/src/effects/desktopgrid/desktopgrid.cpp @@ -179,7 +179,8 @@ void DesktopGridEffect::prePaintScreen(ScreenPrePaintData& data, std::chrono::mi finish(); } - for (auto const &w : effects->stackingOrder()) { + const EffectWindowList windows = effects->stackingOrder(); + for (auto *w : windows) { w->setData(WindowForceBlurRole, QVariant(true)); } @@ -1377,7 +1378,9 @@ QVector DesktopGridEffect::desktopList(const EffectWindow *w) const QVector desks; desks.resize(w->desktops().count()); int i = 0; - for (const int desk : w->desktops()) { + + const QVector allDesks = w->desktops(); + for (const int desk : allDesks) { desks[i++] = desk-1; } return desks; diff --git a/src/effects/overview/overvieweffect.cpp b/src/effects/overview/overvieweffect.cpp index c4d6052dd2..64597cdacc 100644 --- a/src/effects/overview/overvieweffect.cpp +++ b/src/effects/overview/overvieweffect.cpp @@ -246,7 +246,7 @@ void OverviewEffect::activate() void OverviewEffect::deactivate() { - for (OverviewScreenView *screenView : m_screenViews) { + for (OverviewScreenView *screenView : std::as_const(m_screenViews)) { screenView->stop(); } m_shutdownTimer->start(animationDuration()); diff --git a/src/effects/slideback/slideback.cpp b/src/effects/slideback/slideback.cpp index 37dfa484e5..ccda0e21d9 100644 --- a/src/effects/slideback/slideback.cpp +++ b/src/effects/slideback/slideback.cpp @@ -139,7 +139,8 @@ void SlideBackEffect::prePaintScreen(ScreenPrePaintData &data, std::chrono::mill data.mask |= Effect::PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS; } - for (auto const &w : effects->stackingOrder()) { + const EffectWindowList windows = effects->stackingOrder(); + for (auto *w : windows) { w->setData(WindowForceBlurRole, QVariant(true)); } diff --git a/src/input.cpp b/src/input.cpp index b0cd73c235..81de7e64c3 100644 --- a/src/input.cpp +++ b/src/input.cpp @@ -2302,7 +2302,8 @@ void InputRedirection::setupInputFilters() if (m_libInput) { m_tabletSupport = new TabletInputFilter; - for (LibInput::Device *dev : m_libInput->devices()) { + const QVector devices = m_libInput->devices(); + for (LibInput::Device *dev : devices) { m_tabletSupport->integrateDevice(dev); } connect(m_libInput, &LibInput::Connection::deviceAdded, m_tabletSupport, &TabletInputFilter::integrateDevice); diff --git a/src/kcmkwin/kwincompositing/kwincompositingdata.cpp b/src/kcmkwin/kwincompositing/kwincompositingdata.cpp index 41b1ee1b85..5791a43c6b 100644 --- a/src/kcmkwin/kwincompositing/kwincompositingdata.cpp +++ b/src/kcmkwin/kwincompositing/kwincompositingdata.cpp @@ -21,7 +21,9 @@ KWinCompositingData::KWinCompositingData(QObject *parent, const QVariantList &ar bool KWinCompositingData::isDefaults() const { bool defaults = true; - for (const auto &item : m_settings->items()) { + + const KConfigSkeletonItem::List itemList = m_settings->items(); + for (const auto &item : itemList) { if (item->key() != QStringLiteral("OpenGLIsUnsafe")) { defaults &= item->isDefault(); } diff --git a/src/kcmkwin/kwinrules/kcmrules.cpp b/src/kcmkwin/kwinrules/kcmrules.cpp index 822050c609..2f6c3f572e 100644 --- a/src/kcmkwin/kwinrules/kcmrules.cpp +++ b/src/kcmkwin/kwinrules/kcmrules.cpp @@ -260,7 +260,8 @@ void KCMKWinRules::exportToFile(const QUrl &path, const QList &indexes) const auto config = KSharedConfig::openConfig(path.toLocalFile(), KConfig::SimpleConfig); - for (const QString &groupName : config->groupList()) { + const QStringList groups = config->groupList(); + for (const QString &groupName : groups) { config->deleteGroup(groupName); } diff --git a/src/kcmkwin/kwinrules/rulebookmodel.cpp b/src/kcmkwin/kwinrules/rulebookmodel.cpp index f28c71feeb..f3e5df8cff 100644 --- a/src/kcmkwin/kwinrules/rulebookmodel.cpp +++ b/src/kcmkwin/kwinrules/rulebookmodel.cpp @@ -187,7 +187,8 @@ bool RuleBookModel::isSaveNeeded() void RuleBookModel::copySettingsTo(RuleSettings *dest, const RuleSettings &source) { dest->setDefaults(); - for (const KConfigSkeletonItem *item : source.items()) { + const KConfigSkeletonItem::List itemList = source.items(); + for (const KConfigSkeletonItem *item : itemList) { dest->findItem(item->name())->setProperty(item->property()); } } diff --git a/src/virtualdesktops.cpp b/src/virtualdesktops.cpp index 0f4e6eeeee..2d1b1d19c9 100644 --- a/src/virtualdesktops.cpp +++ b/src/virtualdesktops.cpp @@ -104,7 +104,8 @@ void VirtualDesktopManager::setVirtualDesktopManagement(KWaylandServer::PlasmaVi connect(this, &VirtualDesktopManager::currentChanged, m_virtualDesktopManagement, [this]() { - for (auto *deskInt : m_virtualDesktopManagement->desktops()) { + const QList deskIfaces = m_virtualDesktopManagement->desktops(); + for (auto *deskInt : deskIfaces) { if (deskInt->id() == currentDesktop()->id()) { deskInt->setActive(true); } else { diff --git a/src/wayland_server.cpp b/src/wayland_server.cpp index 136d37dac1..6ef2042fff 100644 --- a/src/wayland_server.cpp +++ b/src/wayland_server.cpp @@ -636,7 +636,8 @@ void WaylandServer::initScreenLocker() } ScreenLocker::KSldApp::self()->setWaylandFd(clientFd); - for (auto *seat : m_display->seats()) { + const QVector seatIfaces = m_display->seats(); + for (auto *seat : seatIfaces) { connect(seat, &KWaylandServer::SeatInterface::timestampChanged, screenLockerApp, &ScreenLocker::KSldApp::userActivity); } @@ -651,7 +652,8 @@ void WaylandServer::initScreenLocker() m_screenLockerClientConnection = nullptr; } - for (auto *seat : m_display->seats()) { + const QVector seatIfaces = m_display->seats(); + for (auto *seat : seatIfaces) { disconnect(seat, &KWaylandServer::SeatInterface::timestampChanged, screenLockerApp, &ScreenLocker::KSldApp::userActivity); }