Merge pull request #8364 from sethalves/fix-settings-missing-key

fix bug which caused getValue for a non-existent key to return the integer 2
This commit is contained in:
Brad Davis 2016-08-04 16:39:49 -07:00 committed by GitHub
commit 49ad0951dd
2 changed files with 2 additions and 2 deletions

View file

@ -53,7 +53,7 @@ namespace Setting {
const auto& key = handle->getKey(); const auto& key = handle->getKey();
withWriteLock([&] { withWriteLock([&] {
QVariant loadedValue; QVariant loadedValue;
if (_pendingChanges.contains(key)) { if (_pendingChanges.contains(key) && _pendingChanges[key] != UNSET_VALUE) {
loadedValue = _pendingChanges[key]; loadedValue = _pendingChanges[key];
} else { } else {
loadedValue = value(key); loadedValue = value(key);

View file

@ -46,7 +46,7 @@ namespace Setting {
private: private:
QHash<QString, Interface*> _handles; QHash<QString, Interface*> _handles;
QPointer<QTimer> _saveTimer = nullptr; QPointer<QTimer> _saveTimer = nullptr;
const QVariant UNSET_VALUE { QUuid::createUuid().variant() }; const QVariant UNSET_VALUE { QUuid::createUuid() };
QHash<QString, QVariant> _pendingChanges; QHash<QString, QVariant> _pendingChanges;
friend class Interface; friend class Interface;