From 5687a216cad4b17f0321ae062ac6965a4f54120f Mon Sep 17 00:00:00 2001 From: 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> Date: Fri, 12 Sep 2025 23:38:00 +1000 Subject: plugin/service: fix invoke after destruction --- plugin/src/Caelestia/service.cpp | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'plugin') 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 +#include namespace caelestia { @@ -26,7 +27,15 @@ void Service::ref() { emit refCountChanged(); if (needsStart) { - QMetaObject::invokeMethod(this, &Service::start, Qt::QueuedConnection); + const QPointer 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 self(this); + QMetaObject::invokeMethod( + this, + [self]() { + if (self) { + self->stop(); + } + }, + Qt::QueuedConnection); } } -- cgit v1.2.3-freya