[kdevelop/kdevelop/release/26.08] plugins/custom-definesandincludes/compilerprovider: custom-definesandincludes: when reading settings preserve includes order
Martin Bednár <[email protected]>
| Newsgroups | gmane.comp.kde.cvs |
|---|---|
| Message-ID | <[email protected]> |
Git commit fdca5c81aec03d149f36705ac6ebd8e4e11712d4 by Martin Bednár, on behalf of Benjamin ROBIN.
Committed on 21/07/2026 at 10:43.
Pushed by bednar into branch 'release/26.08'.
custom-definesandincludes: when reading settings preserve includes order
When saving the include paths in doWriteSettings(), each include path is
saved into a configuration entry which key is the index serialized to
string.
When loading the include paths from doReadSettings(), the associated QMap
is retrieved, which by default sort by key. But since the key is not longer
an integer, but a string, then "10" is between "1" and "2".
So to preserve the order, when reading the settings, create a new temporary
QMap which key is an integer.
BUG: 523168
FIXED-IN: 6.5.260800
Pick-to: release/26.08
M +9 -3 plugins/custom-definesandincludes/compilerprovider/settingsmanager.cpp
https://invent.kde.org/kdevelop/kdevelop/-/commit/fdca5c81aec03d149f36705ac6ebd8e4e11712d4
diff --git a/plugins/custom-definesandincludes/compilerprovider/settingsmanager.cpp b/plugins/custom-definesandincludes/compilerprovider/settingsmanager.cpp
index c24bfda0a4..49161ba456 100644
--- a/plugins/custom-definesandincludes/compilerprovider/settingsmanager.cpp
+++ b/plugins/custom-definesandincludes/compilerprovider/settingsmanager.cpp
@@ -224,10 +224,16 @@ QVector<ConfigEntry> doReadSettings( KConfigGroup grp, bool remove = false )
} else {
KConfigGroup includes(pathgrp.group(ConfigConstants::includesKey()));
const QMap<QString, QString> incMap = includes.entryMap();
- for (auto& value :incMap) {
- if(value.isEmpty()){
- continue;
+
+ // Create a new QMap with an integer as key, to preserve the order
+ QMap<int, QString> incMapSorted;
+ for (const auto [key, value] : incMap.asKeyValueRange()) {
+ if (!value.isEmpty()) {
+ incMapSorted[key.toInt()] = value;
}
+ }
+
+ for (auto& value: incMapSorted) {
path.includes += value;
}
}