Commit 6f71ce4d by Carwyn

1. 解决业务插件在主线程调用停止服务卡死问题; 2. 在析构中调用停止服务接口;

parent b7dc6d93
#include "fmp_takeout_p.h"
#include "fmp_te_handlers.h"
FMPTakeout::FMPTakeout(ctkPluginContext *context)
: FMPTakeoutInterface(context),
_inited(false),
d_ptr(new FMPTakeoutPrivate(this))
{
FMPStartEventHandler *se = new FMPStartEventHandler(_ctx, this);
}
FMPTakeout::~FMPTakeout()
{
StopService();
if (d_ptr) {
delete d_ptr;
d_ptr = nullptr;
}
}
void FMPTakeout::InitService()
......
......@@ -14,9 +14,10 @@ class FMPTakeout : public FMPTakeoutInterface
Q_DECLARE_PRIVATE(FMPTakeout)
public:
FMPTakeout(ctkPluginContext *context);
explicit FMPTakeout(ctkPluginContext *context);
virtual ~FMPTakeout();
protected slots:
protected:
void UninitService();
void InitService();
......
......@@ -14,8 +14,8 @@ class FMPTakeoutInterface : public QObject, public FMPluginInterface
public:
explicit FMPTakeoutInterface(ctkPluginContext *ctx) : FMPluginInterface(ctx)
{
connect(this, &FMPTakeoutInterface::TriggerInit, this, &FMPTakeoutInterface::InitService);
connect(this, &FMPTakeoutInterface::TriggerUninit, this, &FMPTakeoutInterface::UninitService);
connect(this, &FMPTakeoutInterface::TriggerInit, this, &FMPTakeoutInterface::OnTriggerInit);
connect(this, &FMPTakeoutInterface::TriggerUninit, this, &FMPTakeoutInterface::OnTriggerUninit);
}
signals:
......@@ -23,8 +23,8 @@ signals:
void TriggerUninit();
protected slots:
void InitService() = 0;
void UninitService() = 0;
void OnTriggerInit() { FMPluginInterface::OnTriggerInit(); }
void OnTriggerUninit() { FMPluginInterface::OnTriggerUninit(); }
};
Q_DECLARE_INTERFACE(FMPTakeoutInterface, "com.fmp.takeout")
......
......@@ -2,7 +2,7 @@
#include "fmp_takeout.h"
FMPStartEventHandler::FMPStartEventHandler(ctkPluginContext *ctx, FMPTakeout *Takeout)
: FMPTakeoutEventHandler(FMP_TOPICS_SERVICES FMPE_SERVICE_REQ_START "/"+ QString::number(ctx->getPlugin()->getPluginId()),
: FMPTakeoutEventHandler(FMP_TOPICS_SERVICES FMPE_SERVICE_ACK_START "/"+ QString::number(ctx->getPlugin()->getPluginId()),
Takeout),
_ctx(ctx)
{
......@@ -16,7 +16,7 @@ void FMPStartEventHandler::handleEvent(const ctkEvent &event)
if (_Takeout) {
if (event.getProperty(FMP_PROPKEY_AGREED).toBool()) {
// _epay->UpgradeOldPlugins(event.getProperty(FMP_PROPKEY_PID_LIST).toList());
// _Takeout->ShowForm();
_Takeout->TriggerInit();
}
else {
// FMP_WARN_CTX(_ctx) << "Refused start request" << event.getTopic();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment