forked from quickshell/quickshell
core/singleton: fix PostReloadHook in singletons
This commit is contained in:
parent
9f38908bdf
commit
31264ac7d1
|
@ -55,16 +55,18 @@ void EngineGeneration::onReload(EngineGeneration* old) {
|
||||||
delete old;
|
delete old;
|
||||||
|
|
||||||
if (old != nullptr) {
|
if (old != nullptr) {
|
||||||
QTimer::singleShot(0, [this]() {
|
QTimer::singleShot(0, [this]() { this->postReload(); });
|
||||||
QuickshellPlugin::runOnReload();
|
|
||||||
PostReloadHook::postReloadTree(this->root);
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
QuickshellPlugin::runOnReload();
|
this->postReload();
|
||||||
PostReloadHook::postReloadTree(this->root);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EngineGeneration::postReload() {
|
||||||
|
QuickshellPlugin::runOnReload();
|
||||||
|
PostReloadHook::postReloadTree(this->root);
|
||||||
|
this->singletonRegistry.onPostReload();
|
||||||
|
}
|
||||||
|
|
||||||
void EngineGeneration::setWatchingFiles(bool watching) {
|
void EngineGeneration::setWatchingFiles(bool watching) {
|
||||||
if (watching) {
|
if (watching) {
|
||||||
if (this->watcher == nullptr) {
|
if (this->watcher == nullptr) {
|
||||||
|
|
|
@ -44,6 +44,7 @@ private slots:
|
||||||
void incubationControllerDestroyed();
|
void incubationControllerDestroyed();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void postReload();
|
||||||
void assignIncubationController();
|
void assignIncubationController();
|
||||||
QVector<QQmlIncubationController*> incubationControllers;
|
QVector<QQmlIncubationController*> incubationControllers;
|
||||||
};
|
};
|
||||||
|
|
|
@ -51,3 +51,9 @@ void SingletonRegistry::onReload(SingletonRegistry* old) {
|
||||||
singleton->onReload(old == nullptr ? nullptr : old->registry.value(url));
|
singleton->onReload(old == nullptr ? nullptr : old->registry.value(url));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SingletonRegistry::onPostReload() {
|
||||||
|
for (auto* singleton: this->registry.values()) {
|
||||||
|
PostReloadHook::postReloadTree(singleton);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@ public:
|
||||||
|
|
||||||
void registerSingleton(const QUrl& url, Singleton* singleton);
|
void registerSingleton(const QUrl& url, Singleton* singleton);
|
||||||
void onReload(SingletonRegistry* old);
|
void onReload(SingletonRegistry* old);
|
||||||
|
void onPostReload();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QHash<QUrl, Singleton*> registry;
|
QHash<QUrl, Singleton*> registry;
|
||||||
|
|
Loading…
Reference in a new issue