summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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);
}
}