Commit 6f71ce4d by Carwyn

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

parent b7dc6d93
#include "fmp_takeout_p.h" #include "fmp_takeout_p.h"
#include "fmp_te_handlers.h"
FMPTakeout::FMPTakeout(ctkPluginContext *context) FMPTakeout::FMPTakeout(ctkPluginContext *context)
: FMPTakeoutInterface(context), : FMPTakeoutInterface(context),
_inited(false), _inited(false),
d_ptr(new FMPTakeoutPrivate(this)) 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() void FMPTakeout::InitService()
......
...@@ -14,11 +14,12 @@ class FMPTakeout : public FMPTakeoutInterface ...@@ -14,11 +14,12 @@ class FMPTakeout : public FMPTakeoutInterface
Q_DECLARE_PRIVATE(FMPTakeout) Q_DECLARE_PRIVATE(FMPTakeout)
public: public:
FMPTakeout(ctkPluginContext *context); explicit FMPTakeout(ctkPluginContext *context);
virtual ~FMPTakeout();
protected slots: protected:
void UninitService(); void UninitService();
void InitService(); void InitService();
private: private:
......
...@@ -12,19 +12,19 @@ class FMPTakeoutInterface : public QObject, public FMPluginInterface ...@@ -12,19 +12,19 @@ class FMPTakeoutInterface : public QObject, public FMPluginInterface
Q_INTERFACES(FMPBaseInterface) Q_INTERFACES(FMPBaseInterface)
Q_INTERFACES(FMPluginInterface) Q_INTERFACES(FMPluginInterface)
public: public:
explicit FMPTakeoutInterface(ctkPluginContext *ctx) : FMPluginInterface(ctx) explicit FMPTakeoutInterface(ctkPluginContext *ctx) : FMPluginInterface(ctx)
{ {
connect(this, &FMPTakeoutInterface::TriggerInit, this, &FMPTakeoutInterface::InitService); connect(this, &FMPTakeoutInterface::TriggerInit, this, &FMPTakeoutInterface::OnTriggerInit);
connect(this, &FMPTakeoutInterface::TriggerUninit, this, &FMPTakeoutInterface::UninitService); connect(this, &FMPTakeoutInterface::TriggerUninit, this, &FMPTakeoutInterface::OnTriggerUninit);
} }
signals: signals:
void TriggerInit(); void TriggerInit();
void TriggerUninit(); void TriggerUninit();
protected slots: protected slots:
void InitService() = 0; void OnTriggerInit() { FMPluginInterface::OnTriggerInit(); }
void UninitService() = 0; void OnTriggerUninit() { FMPluginInterface::OnTriggerUninit(); }
}; };
Q_DECLARE_INTERFACE(FMPTakeoutInterface, "com.fmp.takeout") Q_DECLARE_INTERFACE(FMPTakeoutInterface, "com.fmp.takeout")
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
#include "fmp_takeout.h" #include "fmp_takeout.h"
FMPStartEventHandler::FMPStartEventHandler(ctkPluginContext *ctx, FMPTakeout *Takeout) 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), Takeout),
_ctx(ctx) _ctx(ctx)
{ {
...@@ -16,7 +16,7 @@ void FMPStartEventHandler::handleEvent(const ctkEvent &event) ...@@ -16,7 +16,7 @@ void FMPStartEventHandler::handleEvent(const ctkEvent &event)
if (_Takeout) { if (_Takeout) {
if (event.getProperty(FMP_PROPKEY_AGREED).toBool()) { if (event.getProperty(FMP_PROPKEY_AGREED).toBool()) {
// _epay->UpgradeOldPlugins(event.getProperty(FMP_PROPKEY_PID_LIST).toList()); // _epay->UpgradeOldPlugins(event.getProperty(FMP_PROPKEY_PID_LIST).toList());
// _Takeout->ShowForm(); _Takeout->TriggerInit();
} }
else { else {
// FMP_WARN_CTX(_ctx) << "Refused start request" << event.getTopic(); // 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