aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLieven Hey <lieven.hey@kdab.com>2021-05-20 12:29:04 +0200
committerLieven Hey <lieven.hey@kdab.com>2021-05-25 09:35:18 +0200
commitb3dc879e8b108c26c929bfbe551bcdf77f140e94 (patch)
tree0c365aa7953c2f488009c7add3ddcf6aae24f205
parentaf6982ba361b7b5b11c732d2f7286801e0391d51 (diff)
downloadkconfig-b3dc879e8b108c26c929bfbe551bcdf77f140e94.tar.gz
kconfig-b3dc879e8b108c26c929bfbe551bcdf77f140e94.tar.bz2
fix deleted group is in listGroups
calling deleteGroup only deletes all entries but the group does still exists in listGroups this is somewhat irritating since calling exists on that group will return false with this patch the group does no longer exists in listGroup
-rw-r--r--autotests/kconfigtest.cpp2
-rw-r--r--src/core/kconfig.cpp4
2 files changed, 3 insertions, 3 deletions
diff --git a/autotests/kconfigtest.cpp b/autotests/kconfigtest.cpp
index bf7882f0..e6a3e645 100644
--- a/autotests/kconfigtest.cpp
+++ b/autotests/kconfigtest.cpp
@@ -802,7 +802,7 @@ void KConfigTest::testDelete()
delgr.deleteGroup();
QVERIFY(!delgr.exists());
QVERIFY(!ct.hasGroup("Nested Group 3"));
- QVERIFY(ct.groupList().contains(QStringLiteral("Nested Group 3")));
+ QVERIFY(!ct.groupList().contains(QStringLiteral("Nested Group 3")));
KConfigGroup ng(&ct, "Nested Group 2");
QVERIFY(sc.hasGroup("Complex Types"));
diff --git a/src/core/kconfig.cpp b/src/core/kconfig.cpp
index cc3700e1..49a66d14 100644
--- a/src/core/kconfig.cpp
+++ b/src/core/kconfig.cpp
@@ -269,7 +269,7 @@ QStringList KConfig::groupList() const
for (auto entryMapIt = d->entryMap.cbegin(); entryMapIt != d->entryMap.cend(); ++entryMapIt) {
const KEntryKey &key = entryMapIt.key();
const QByteArray group = key.mGroup;
- if (key.mKey.isNull() && !group.isEmpty() && group != "<default>" && group != "$Version") {
+ if (key.mKey.isNull() && !group.isEmpty() && group != "<default>" && group != "$Version" && !d->hasNonDeletedEntries(group)) {
const QString groupname = QString::fromUtf8(group);
groups << groupname.left(groupname.indexOf(QLatin1Char('\x1d')));
}
@@ -285,7 +285,7 @@ QStringList KConfigPrivate::groupList(const QByteArray &group) const
for (auto entryMapIt = entryMap.cbegin(); entryMapIt != entryMap.cend(); ++entryMapIt) {
const KEntryKey &key = entryMapIt.key();
- if (key.mKey.isNull() && key.mGroup.startsWith(theGroup)) {
+ if (key.mKey.isNull() && key.mGroup.startsWith(theGroup) && !hasNonDeletedEntries(group)) {
const QString groupname = QString::fromUtf8(key.mGroup.mid(theGroup.length()));
groups << groupname.left(groupname.indexOf(QLatin1Char('\x1d')));
}