Fixing settings, even in release builds

This commit is contained in:
Bradley Austin Davis 2016-06-14 12:13:27 -07:00
parent d52a1fe6f9
commit b1c472e82b
2 changed files with 8 additions and 1 deletions

View file

@ -97,7 +97,7 @@ namespace Setting {
void set(const T& value) {
maybeInit();
if (_value != value) {
if ((!_isSet && (value != _defaultValue)) || _value != value) {
_value = value;
_isSet = true;
save();

View file

@ -96,6 +96,7 @@ namespace Setting {
}
void Manager::saveAll() {
bool forceSync = false;
withWriteLock([&] {
for (auto key : _pendingChanges.keys()) {
auto newValue = _pendingChanges[key];
@ -104,14 +105,20 @@ namespace Setting {
continue;
}
if (newValue == UNSET_VALUE || !newValue.isValid()) {
forceSync = true;
remove(key);
} else {
forceSync = true;
setValue(key, newValue);
}
}
_pendingChanges.clear();
});
if (forceSync) {
sync();
}
// Restart timer
if (_saveTimer) {
_saveTimer->start();