diff --git a/src/Gui/KSMainWindow.cpp b/src/Gui/KSMainWindow.cpp --- a/src/Gui/KSMainWindow.cpp +++ b/src/Gui/KSMainWindow.cpp @@ -378,7 +378,8 @@ void KSMainWindow::showInlineMessage(const QString& message, const KMessageWidget::MessageType messageType, const MessageDuration messageDuration, const QList& actions) { - for (QAction* action: mMessageWidget->actions()) { + const auto messageWidgetActions = mMessageWidget->actions(); + for (QAction* action: messageWidgetActions) { mMessageWidget->removeAction(action); } for (QAction* action : actions) { diff --git a/src/Platforms/PlatformXcb.cpp b/src/Platforms/PlatformXcb.cpp --- a/src/Platforms/PlatformXcb.cpp +++ b/src/Platforms/PlatformXcb.cpp @@ -401,7 +401,8 @@ theRect = getDrawableGeometry(lRootWindow); } else { QRegion lScreenRegion; - for (auto lScreen: QGuiApplication::screens()) { + const auto lScreens = QGuiApplication::screens(); + for (auto lScreen: lScreens) { auto lScreenRect = lScreen->geometry(); // Do not use setSize() here, because QSize::operator*=() @@ -473,7 +474,8 @@ void PlatformXcb::grabCurrentScreen(bool theIncludePointer) { auto lCursorPosition = QCursor::pos(); - for (auto lScreen: QGuiApplication::screens()) { + const auto lScreens = QGuiApplication::screens(); + for (auto lScreen: lScreens) { auto lScreenRect = lScreen->geometry(); if (!lScreenRect.contains(lCursorPosition)) { continue;