core/reloader: trigger onPostReload if launched post-reload

This is similar to the check in Reloadable, and fixes a number of hard
to debug issues with Process, IpcHandler, NotificationServer, and
GlobalShortcut not working depending on where you put them in a QML file.
This commit is contained in:
outfoxxed 2025-07-04 15:58:41 -07:00
parent 0e6518a706
commit 9708d8212a
Signed by untrusted user: outfoxxed
GPG key ID: 4C88A185FB89301E
8 changed files with 36 additions and 38 deletions

View file

@ -126,12 +126,17 @@ QObject* Reloadable::getChildByReloadId(QObject* parent, const QString& reloadId
return nullptr;
}
void PostReloadHook::postReloadTree(QObject* root) {
for (auto* child: root->children()) {
PostReloadHook::postReloadTree(child);
}
if (auto* self = dynamic_cast<PostReloadHook*>(root)) {
self->onPostReload();
}
void PostReloadHook::componentComplete() {
auto* engineGeneration = EngineGeneration::findObjectGeneration(this);
if (!engineGeneration || engineGeneration->reloadComplete) this->postReload();
}
void PostReloadHook::postReload() {
this->isPostReload = true;
this->onPostReload();
}
void PostReloadHook::postReloadTree(QObject* root) {
for (auto* child: root->children()) PostReloadHook::postReloadTree(child);
if (auto* self = dynamic_cast<PostReloadHook*>(root)) self->postReload();
}