mirror of
https://github.com/quickshell-mirror/quickshell.git
synced 2026-10-27 02:54:36 +00:00
core/singleton: fix PostReloadHook in singletons
This commit is contained in:
4 files changed
+16
-6
No files matched your search
@@ -55,16 +55,18 @@ void EngineGeneration::onReload(EngineGeneration* old) {
|
||||
delete old;
|
||||
|
||||
if (old != nullptr) {
|
||||
QTimer::singleShot(0, [this]() {
|
||||
QuickshellPlugin::runOnReload();
|
||||
PostReloadHook::postReloadTree(this->root);
|
||||
});
|
||||
QTimer::singleShot(0, [this]() { this->postReload(); });
|
||||
} else {
|
||||
QuickshellPlugin::runOnReload();
|
||||
PostReloadHook::postReloadTree(this->root);
|
||||
this->postReload();
|
||||
}
|
||||
}
|
||||
|
||||
void EngineGeneration::postReload() {
|
||||
QuickshellPlugin::runOnReload();
|
||||
PostReloadHook::postReloadTree(this->root);
|
||||
this->singletonRegistry.onPostReload();
|
||||
}
|
||||
|
||||
void EngineGeneration::setWatchingFiles(bool watching) {
|
||||
if (watching) {
|
||||
if (this->watcher == nullptr) {
|
||||
|
||||
@@ -44,6 +44,7 @@ private slots:
|
||||
void incubationControllerDestroyed();
|
||||
|
||||
private:
|
||||
void postReload();
|
||||
void assignIncubationController();
|
||||
QVector<QQmlIncubationController*> incubationControllers;
|
||||
};
|
||||
@@ -51,3 +51,9 @@ void SingletonRegistry::onReload(SingletonRegistry* old) {
|
||||
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 onReload(SingletonRegistry* old);
|
||||
void onPostReload();
|
||||
|
||||
private:
|
||||
QHash<QUrl, Singleton*> registry;
|
||||
|
||||
Reference in new issue
Block a user