Windows: Fix handling of childGroups() when fallbacks are disabled

When fallbacks are disabled for QSettings then it should not be
falling back to any child groups or keys that might exist in a
fallback set of settings.

Fixes: QTBUG-85295
Change-Id: I563999293a103702035c8d3b027b59b94ca43c0e
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
bb10
Jeremie Graulle 2020-07-02 01:43:10 +02:00 committed by Andy Shaw
parent be5508fad0
commit 3162f04dee
2 changed files with 20 additions and 4 deletions

View File

@ -759,11 +759,17 @@ QStringList QWinSettingsPrivate::children(const QString &uKey, ChildSpec spec) c
for (const RegistryKey &r : regList) {
HKEY parent_handle = r.handle();
if (parent_handle == 0)
continue;
if (parent_handle == 0) {
if (fallbacks)
continue;
break;
}
HKEY handle = openKey(parent_handle, KEY_READ, rKey, access);
if (handle == 0)
continue;
if (handle == 0) {
if (fallbacks)
continue;
break;
}
if (spec == AllKeys) {
NameSet keys;

View File

@ -2018,6 +2018,16 @@ void tst_QSettings::testChildKeysAndGroups()
l.sort();
QCOMPARE(l, QStringList() << "bar" << "foo");
}
{
QSettings settings3(format, QSettings::UserScope, "software.org", "application");
settings3.setFallbacksEnabled(false);
settings3.beginGroup("alpha");
QCOMPARE(settings3.childGroups(), QStringList());
settings3.setFallbacksEnabled(true);
QStringList children = settings3.childGroups();
children.sort();
QCOMPARE(children, QStringList({"beta", "gamma"}));
}
}
void tst_QSettings::testUpdateRequestEvent()