fix compilation error
fixes: #191 Signed-off-by: Yuhang Zhao <2546789017@qq.com>
This commit is contained in:
parent
4844257fc8
commit
8683a14a3c
|
@ -83,9 +83,9 @@ private:
|
|||
Global::RegistryRootKey m_rootKey = Global::RegistryRootKey::CurrentUser;
|
||||
QString m_subKey = {};
|
||||
#if REGISTRYKEY_QWINREGISTRYKEY
|
||||
std::unique_ptr<QWinRegistryKey> m_registryKey = nullptr;
|
||||
QScopedPointer<QWinRegistryKey> m_registryKey;
|
||||
#else
|
||||
std::unique_ptr<QSettings> m_settings = nullptr;
|
||||
QScopedPointer<QSettings> m_settings;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
|
|
@ -85,17 +85,16 @@ RegistryKey::RegistryKey(const RegistryRootKey root, const QString &key, QObject
|
|||
m_rootKey = root;
|
||||
m_subKey = key;
|
||||
#if REGISTRYKEY_QWINREGISTRYKEY
|
||||
m_registryKey = std::make_unique<QWinRegistryKey>(g_keyMap[static_cast<int>(m_rootKey)], m_subKey);
|
||||
m_registryKey.reset(new QWinRegistryKey(g_keyMap[static_cast<int>(m_rootKey)], m_subKey));
|
||||
if (!m_registryKey->isValid()) {
|
||||
m_registryKey.reset();
|
||||
}
|
||||
#else
|
||||
const QString rootKey = g_strMap[static_cast<int>(m_rootKey)];
|
||||
const auto lastSlashPos = m_subKey.lastIndexOf(u'\\');
|
||||
m_settings = std::make_unique<QSettings>(rootKey + u'\\' + m_subKey.left(lastSlashPos), QSettings::NativeFormat);
|
||||
m_settings.reset(new QSettings(rootKey + u'\\' + m_subKey.left(lastSlashPos), QSettings::NativeFormat));
|
||||
if (m_settings->childGroups().contains(m_subKey.mid(lastSlashPos + 1))) {
|
||||
m_settings.reset();
|
||||
m_settings = std::make_unique<QSettings>(rootKey + u'\\' + m_subKey, QSettings::NativeFormat);
|
||||
m_settings.reset(new QSettings(rootKey + u'\\' + m_subKey, QSettings::NativeFormat));
|
||||
} else {
|
||||
m_settings.reset();
|
||||
}
|
||||
|
@ -117,9 +116,9 @@ QString RegistryKey::subKey() const
|
|||
bool RegistryKey::isValid() const
|
||||
{
|
||||
#if REGISTRYKEY_QWINREGISTRYKEY
|
||||
return (m_registryKey && m_registryKey->isValid());
|
||||
return (!m_registryKey.isNull() && m_registryKey->isValid());
|
||||
#else
|
||||
return m_settings;
|
||||
return !m_settings.isNull();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue