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

Christoph Grüninger <[email protected]>
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit f7cc2b2fca8a9cc276ab7bedba11cc61c6f57401 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

Use std::to_array<QString> instead of QStringList.
Found by Clazy (range-loop-detach).

M  +2    -2    kcms/tablet/kcmtablet.cpp

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

diff --git a/kcms/tablet/kcmtablet.cpp b/kcms/tablet/kcmtablet.cpp
index 2f5a6a2268..15414ddc22 100644
--- a/kcms/tablet/kcmtablet.cpp
+++ b/kcms/tablet/kcmtablet.cpp
@@ -369,7 +369,7 @@ void Tablet::save()
 
     auto generalGroup = KSharedConfig::openConfig("kcminputrc")->group("ButtonRebinds");
     // regular rebinds
-    for (const auto &device : QStringList{"Tablet", "TabletTool", "TabletDial"}) {
+    for (const auto &device : std::to_array<QString>({"Tablet", "TabletTool", "TabletDial"})) {
         for (auto it = m_unsavedMappings[device].cbegin(), itEnd = m_unsavedMappings[device].cend(); it != itEnd; ++it) {
             auto configGroup = generalGroup.group(device).group(it.key());
             for (auto itDevice = it->cbegin(), itDeviceEnd = it->cend(); itDevice != itDeviceEnd; ++itDevice) {
@@ -385,7 +385,7 @@ void Tablet::save()
         }
     }
     // mode-based rebinds
-    for (const auto &device : QStringList{"TabletRing"}) {
+    for (const auto &device : std::to_array<QString>({"TabletRing"})) {
         for (auto it = m_unsavedMappings[device].cbegin(), itEnd = m_unsavedMappings[device].cend(); it != itEnd; ++it) {
             auto configGroup = generalGroup.group(device).group(it.key());
             for (auto itDevice = it->cbegin(), itDeviceEnd = it->cend(); itDevice != itDeviceEnd; ++itDevice) {
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.