summaryrefslogtreecommitdiff
path: root/plugin/src
diff options
context:
space:
mode:
author2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>2025-09-12 23:38:00 +1000
committer2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>2025-09-12 23:38:00 +1000
commit5687a216cad4b17f0321ae062ac6965a4f54120f (patch)
treeece5a5c45b31399c0c347fa380dcc8d58fc7f9bd /plugin/src
parentinternal: fix crash (diff)
downloadcaelestia-shell-5687a216cad4b17f0321ae062ac6965a4f54120f.tar.gz
caelestia-shell-5687a216cad4b17f0321ae062ac6965a4f54120f.tar.bz2
caelestia-shell-5687a216cad4b17f0321ae062ac6965a4f54120f.zip
plugin/service: fix invoke after destruction
Diffstat (limited to 'plugin/src')
-rw-r--r--plugin/src/Caelestia/service.cpp21
1 files changed, 19 insertions, 2 deletions
diff --git a/plugin/src/Caelestia/service.cpp b/plugin/src/Caelestia/service.cpp
index 941138f..bc919c9 100644
--- a/plugin/src/Caelestia/service.cpp
+++ b/plugin/src/Caelestia/service.cpp
@@ -1,6 +1,7 @@
#include "service.hpp"
#include <qdebug.h>
+#include <qpointer.h>
namespace caelestia {
@@ -26,7 +27,15 @@ void Service::ref() {
emit refCountChanged();
if (needsStart) {
- QMetaObject::invokeMethod(this, &Service::start, Qt::QueuedConnection);
+ const QPointer<Service> self(this);
+ QMetaObject::invokeMethod(
+ this,
+ [self]() {
+ if (self) {
+ self->start();
+ }
+ },
+ Qt::QueuedConnection);
}
}
@@ -46,7 +55,15 @@ void Service::unref() {
emit refCountChanged();
if (needsStop) {
- QMetaObject::invokeMethod(this, &Service::stop, Qt::QueuedConnection);
+ const QPointer<Service> self(this);
+ QMetaObject::invokeMethod(
+ this,
+ [self]() {
+ if (self) {
+ self->stop();
+ }
+ },
+ Qt::QueuedConnection);
}
}