fix: remove key from loaded keys on sync
A sync goes through the property setter, which sets the key as loaded. But a sync is not considered an explicit set, so unset it after
This commit is contained in:
parent
9b1b33a388
commit
697784abce
1 changed files with 7 additions and 1 deletions
|
|
@ -161,6 +161,7 @@ void ConfigObject::syncFromGlobal(ConfigObject* global) {
|
||||||
if (!m_loadedKeys.contains(key)) {
|
if (!m_loadedKeys.contains(key)) {
|
||||||
auto val = prop.read(global);
|
auto val = prop.read(global);
|
||||||
prop.write(this, val);
|
prop.write(this, val);
|
||||||
|
m_loadedKeys.remove(key); // setter added it — remove since this is a synced value
|
||||||
qCDebug(lcConfig) << " Synced" << key << "=" << val << "from global";
|
qCDebug(lcConfig) << " Synced" << key << "=" << val << "from global";
|
||||||
} else {
|
} else {
|
||||||
qCDebug(lcConfig) << " Keeping loaded" << key << "=" << prop.read(this);
|
qCDebug(lcConfig) << " Keeping loaded" << key << "=" << prop.read(this);
|
||||||
|
|
@ -206,8 +207,10 @@ void ConfigObject::resyncFromGlobal() {
|
||||||
if (!prop.isWritable())
|
if (!prop.isWritable())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (!m_loadedKeys.contains(key))
|
if (!m_loadedKeys.contains(key)) {
|
||||||
prop.write(this, prop.read(m_global));
|
prop.write(this, prop.read(m_global));
|
||||||
|
m_loadedKeys.remove(key); // setter added it — remove since this is a synced value
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -219,6 +222,9 @@ void ConfigObject::onGlobalPropertiesChanged(const QMap<QString, QVariant>& chan
|
||||||
int idx = metaObject()->indexOfProperty(it.key().toUtf8().constData());
|
int idx = metaObject()->indexOfProperty(it.key().toUtf8().constData());
|
||||||
if (idx >= 0) {
|
if (idx >= 0) {
|
||||||
metaObject()->property(idx).write(this, it.value());
|
metaObject()->property(idx).write(this, it.value());
|
||||||
|
// Remove the key that was added by markPropertyLoaded in the setter —
|
||||||
|
// this is a synced value, not an explicit override
|
||||||
|
m_loadedKeys.remove(it.key());
|
||||||
qCDebug(lcConfig) << metaObject()->className() << "synced" << it.key() << "=" << it.value()
|
qCDebug(lcConfig) << metaObject()->className() << "synced" << it.key() << "=" << it.value()
|
||||||
<< "from global change";
|
<< "from global change";
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue