diff options
author | Yuhang Zhao <2546789017@qq.com> | 2022-10-21 20:54:10 +0800 |
---|---|---|
committer | Yuhang Zhao <2546789017@qq.com> | 2022-10-28 09:27:13 +0000 |
commit | 32774f13d961c138f82dc50c085c1d66d0a91dd1 (patch) | |
tree | eb23b29139874d8885970a3803db73e97fa50baf /src/corelib/kernel | |
parent | 19857fda75d049e64e39ff353d7f5ed3bd342d61 (diff) |
QWinRegistryKey: Fix how we handle the default value, take 2
It seems the value name correction is not needed at all,
and we must not do such correction.
Amends commit 738e05a55a4047268553eea6b9f4809d42181eef
Task-number: QTBUG-107794
Change-Id: I903a762aafab4b55275beb8438e6769285821567
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Diffstat (limited to 'src/corelib/kernel')
-rw-r--r-- | src/corelib/kernel/qwinregistry.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/corelib/kernel/qwinregistry.cpp b/src/corelib/kernel/qwinregistry.cpp index fe0cd62bdd..dc5252f9d1 100644 --- a/src/corelib/kernel/qwinregistry.cpp +++ b/src/corelib/kernel/qwinregistry.cpp @@ -38,13 +38,14 @@ void QWinRegistryKey::close() QVariant QWinRegistryKey::value(QStringView subKey) const { + // NOTE: Empty value name is allowed in Windows registry, it means the default + // or unnamed value of a key, you can read/write/delete such value normally. + if (!isValid()) return {}; - if (subKey.isEmpty()) - subKey = u"Default"; - - auto subKeyC = reinterpret_cast<const wchar_t *>(subKey.utf16()); + // Use nullptr when we need to access the default value. + const auto subKeyC = subKey.isEmpty() ? nullptr : reinterpret_cast<const wchar_t *>(subKey.utf16()); // Get the size and type of the value. DWORD dataType = REG_NONE; |