fix bug which caused getValue for a non-existent key to return the integer 2

This commit is contained in:
Seth Alves 2016-08-04 10:16:08 -07:00
parent a1dc9beddb
commit 4c258b9568
2 changed files with 4 additions and 5 deletions

View file

@ -70,12 +70,11 @@ namespace Setting {
QVariant handleValue = UNSET_VALUE; QVariant handleValue = UNSET_VALUE;
if (handle->isSet()) { if (handle->isSet()) {
handleValue = handle->getVariant(); handleValue = handle->getVariant();
}
withWriteLock([&] { withWriteLock([&] {
_pendingChanges[key] = handleValue; _pendingChanges[key] = handleValue;
}); });
} }
}
static const int SAVE_INTERVAL_MSEC = 5 * 1000; // 5 sec static const int SAVE_INTERVAL_MSEC = 5 * 1000; // 5 sec
void Manager::startTimer() { void Manager::startTimer() {

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;