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;
|
Global::RegistryRootKey m_rootKey = Global::RegistryRootKey::CurrentUser;
|
||||||
QString m_subKey = {};
|
QString m_subKey = {};
|
||||||
#if REGISTRYKEY_QWINREGISTRYKEY
|
#if REGISTRYKEY_QWINREGISTRYKEY
|
||||||
std::unique_ptr<QWinRegistryKey> m_registryKey = nullptr;
|
QScopedPointer<QWinRegistryKey> m_registryKey;
|
||||||
#else
|
#else
|
||||||
std::unique_ptr<QSettings> m_settings = nullptr;
|
QScopedPointer<QSettings> m_settings;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -85,17 +85,16 @@ RegistryKey::RegistryKey(const RegistryRootKey root, const QString &key, QObject
|
||||||
m_rootKey = root;
|
m_rootKey = root;
|
||||||
m_subKey = key;
|
m_subKey = key;
|
||||||
#if REGISTRYKEY_QWINREGISTRYKEY
|
#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()) {
|
if (!m_registryKey->isValid()) {
|
||||||
m_registryKey.reset();
|
m_registryKey.reset();
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
const QString rootKey = g_strMap[static_cast<int>(m_rootKey)];
|
const QString rootKey = g_strMap[static_cast<int>(m_rootKey)];
|
||||||
const auto lastSlashPos = m_subKey.lastIndexOf(u'\\');
|
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))) {
|
if (m_settings->childGroups().contains(m_subKey.mid(lastSlashPos + 1))) {
|
||||||
m_settings.reset();
|
m_settings.reset(new QSettings(rootKey + u'\\' + m_subKey, QSettings::NativeFormat));
|
||||||
m_settings = std::make_unique<QSettings>(rootKey + u'\\' + m_subKey, QSettings::NativeFormat);
|
|
||||||
} else {
|
} else {
|
||||||
m_settings.reset();
|
m_settings.reset();
|
||||||
}
|
}
|
||||||
|
@ -117,9 +116,9 @@ QString RegistryKey::subKey() const
|
||||||
bool RegistryKey::isValid() const
|
bool RegistryKey::isValid() const
|
||||||
{
|
{
|
||||||
#if REGISTRYKEY_QWINREGISTRYKEY
|
#if REGISTRYKEY_QWINREGISTRYKEY
|
||||||
return (m_registryKey && m_registryKey->isValid());
|
return (!m_registryKey.isNull() && m_registryKey->isValid());
|
||||||
#else
|
#else
|
||||||
return m_settings;
|
return !m_settings.isNull();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue