[plasma/plasma-desktop] /: Prevent detaching in range-based for-loop

Christoph Grüninger <[email protected]>
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit e7dfe6cf6140ad3b7890ae0a8589a3ed22d384a3 by Christoph Grüninger.
Committed on 19/07/2026 at 14:30.
Pushed by davidedmundson into branch 'master'.

Prevent detaching in range-based for-loop

Make container const.
Found by Clazy (range-loop-detach).

M  +1    -1    emojier/emojierplugin.cpp
M  +2    -2    kcms/tablet/kcmtablet.cpp
M  +1    -1    kcms/touchscreen/kcmtouchscreen.cpp

https://invent.kde.org/plasma/plasma-desktop/-/commit/e7dfe6cf6140ad3b7890ae0a8589a3ed22d384a3

diff --git a/emojier/emojierplugin.cpp b/emojier/emojierplugin.cpp
index 1f9c5e31cb..797842d8e3 100644
--- a/emojier/emojierplugin.cpp
+++ b/emojier/emojierplugin.cpp
@@ -263,7 +263,7 @@ void RecentEmojiModel::refresh()
     const auto oldCount = m_emoji.count();
 
     beginResetModel();
-    auto recent = m_settings.recent();
+    const auto recent = m_settings.recent();
     auto recentDescriptions = m_settings.recentDescriptions();
     int i = 0;
     m_emoji.clear();
diff --git a/kcms/tablet/kcmtablet.cpp b/kcms/tablet/kcmtablet.cpp
index dae330829e..2f5a6a2268 100644
--- a/kcms/tablet/kcmtablet.cpp
+++ b/kcms/tablet/kcmtablet.cpp
@@ -86,7 +86,7 @@ public:
     {
         clear();
 
-        auto screens = qGuiApp->screens();
+        const auto screens = qGuiApp->screens();
         auto it = new QStandardItem(i18n("Follow the Current Screen"));
         it->setData(screens[0]->physicalSize(), Qt::UserRole + 1); // we use the first display to give an idea
         it->setData(screens[0]->size(), Qt::UserRole + 2);
@@ -97,7 +97,7 @@ public:
         it->setData(screens[0]->virtualSize(), Qt::UserRole + 2);
         appendRow(it);
 
-        for (auto screen : screens) {
+        for (const auto screen : screens) {
             auto geo = screen->geometry();
             auto name = screen->model().isEmpty() ? screen->name() : screen->model();
             auto it = new QStandardItem(i18nc("model - (x,y widthxheight)",
diff --git a/kcms/touchscreen/kcmtouchscreen.cpp b/kcms/touchscreen/kcmtouchscreen.cpp
index efc27708af..c2191a276d 100644
--- a/kcms/touchscreen/kcmtouchscreen.cpp
+++ b/kcms/touchscreen/kcmtouchscreen.cpp
@@ -45,10 +45,10 @@ public:
     {
         clear();
 
-        auto screens = qGuiApp->screens();
         auto it = new QStandardItem(i18n("Automatic"));
         appendRow(it);
 
+        const auto screens = qGuiApp->screens();
         for (auto screen : screens) {
             auto geo = screen->geometry();
             auto it = new QStandardItem(i18nc("model - (x,y widthxheight)",
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.