Prevent saving invalid values

If a value has not changed and should be saved to a file, only the key (and the invalid value) was passed to the save function. The save function does not check this case or read the value from the cache.
This happens when changing simulator paths as the settings are updated and saved separately.
This commit is contained in:
Lars Toenning
2022-04-05 17:49:04 +02:00
committed by Mat Sutcliffe
parent 05293feb8f
commit d4fdc6e17b
3 changed files with 9 additions and 9 deletions

View File

@@ -404,7 +404,7 @@ namespace BlackMisc
CStatusMessage setAndSave(const T &value, qint64 timestamp = 0) { return m_page->setValue(*m_element, CVariant::from(value), timestamp, true); }
//! Save using the currently set value. Must be called from the thread in which the owner lives.
CStatusMessage save() { return m_page->setValue(*m_element, {}, 0, true, true); }
CStatusMessage save() { return m_page->setValue(*m_element, {}, 0, true); }
//! Write a property of the value. Must be called from the thread in which the owner lives.
CStatusMessage setProperty(CPropertyIndexRef index, const CVariant &value, qint64 timestamp = 0) { auto v = get(); v.setPropertyByIndex(index, value); return set(v, timestamp); }