mirror of
https://git.outfoxxed.me/quickshell/quickshell.git
synced 2025-11-04 19:04:56 +11:00
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:
parent
0e6518a706
commit
9708d8212a
8 changed files with 36 additions and 38 deletions
|
|
@ -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();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -119,16 +119,19 @@ private:
|
|||
};
|
||||
|
||||
/// Hook that runs after the old widget tree is dropped during a reload.
|
||||
class PostReloadHook {
|
||||
class PostReloadHook
|
||||
: public QObject
|
||||
, public QQmlParserStatus {
|
||||
public:
|
||||
PostReloadHook() = default;
|
||||
virtual ~PostReloadHook() = default;
|
||||
PostReloadHook(PostReloadHook&&) = default;
|
||||
PostReloadHook(const PostReloadHook&) = default;
|
||||
PostReloadHook& operator=(PostReloadHook&&) = default;
|
||||
PostReloadHook& operator=(const PostReloadHook&) = default;
|
||||
PostReloadHook(QObject* parent = nullptr): QObject(parent) {}
|
||||
void classBegin() override {}
|
||||
void componentComplete() override;
|
||||
|
||||
void postReload();
|
||||
virtual void onPostReload() = 0;
|
||||
|
||||
static void postReloadTree(QObject* root);
|
||||
|
||||
protected:
|
||||
bool isPostReload = false;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue