variants: fix onReload not being called after variant updates

This commit is contained in:
outfoxxed 2024-03-09 02:35:07 -08:00
parent a35d3f9584
commit fc93591cab
Signed by: outfoxxed
GPG key ID: 4C88A185FB89301E
2 changed files with 8 additions and 0 deletions

View file

@ -46,6 +46,8 @@ void Variants::onReload(QObject* oldInstance) {
if (instance != nullptr) instance->onReload(oldInstance);
else Reloadable::reloadChildrenRecursive(instanceObj, oldInstance);
}
this->loaded = true;
}
void Variants::setVariants(QVariantList variants) {
@ -108,6 +110,11 @@ void Variants::updateVariants() {
instance->setParent(this);
this->instances.insert(variant, instance);
if (this->loaded) {
if (auto* reloadable = qobject_cast<Reloadable*>(instance)) reloadable->onReload(nullptr);
else Reloadable::reloadChildrenRecursive(instance, nullptr);
}
}
outer:;

View file

@ -53,4 +53,5 @@ private:
QQmlComponent* mComponent = nullptr;
QVariantList mVariants;
AwfulMap<QVariantMap, QObject*> instances;
bool loaded = false;
};