plugin/service: fix invoke after destruction
This commit is contained in:
parent
56f6150ec9
commit
5687a216ca
1 changed files with 19 additions and 2 deletions
|
|
@ -1,6 +1,7 @@
|
||||||
#include "service.hpp"
|
#include "service.hpp"
|
||||||
|
|
||||||
#include <qdebug.h>
|
#include <qdebug.h>
|
||||||
|
#include <qpointer.h>
|
||||||
|
|
||||||
namespace caelestia {
|
namespace caelestia {
|
||||||
|
|
||||||
|
|
@ -26,7 +27,15 @@ void Service::ref() {
|
||||||
emit refCountChanged();
|
emit refCountChanged();
|
||||||
|
|
||||||
if (needsStart) {
|
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();
|
emit refCountChanged();
|
||||||
|
|
||||||
if (needsStop) {
|
if (needsStop) {
|
||||||
QMetaObject::invokeMethod(this, &Service::stop, Qt::QueuedConnection);
|
const QPointer<Service> self(this);
|
||||||
|
QMetaObject::invokeMethod(
|
||||||
|
this,
|
||||||
|
[self]() {
|
||||||
|
if (self) {
|
||||||
|
self->stop();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
Qt::QueuedConnection);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue