Commit acf4517e by Carwyn

1. 解决业务插件在主线程调用停止服务卡死问题;

parent 32832ecf
...@@ -9,6 +9,8 @@ class FMPHome; ...@@ -9,6 +9,8 @@ class FMPHome;
class FMPHomeEventHandler : public QObject, public ctkEventHandler class FMPHomeEventHandler : public QObject, public ctkEventHandler
{ {
Q_OBJECT
Q_INTERFACES(ctkEventHandler)
public: public:
explicit FMPHomeEventHandler(const QString &topic, FMPHome *home, ctkPluginContext *ctx); explicit FMPHomeEventHandler(const QString &topic, FMPHome *home, ctkPluginContext *ctx);
...@@ -20,8 +22,6 @@ protected: ...@@ -20,8 +22,6 @@ protected:
class FMPStartEventHandler : public FMPHomeEventHandler class FMPStartEventHandler : public FMPHomeEventHandler
{ {
Q_OBJECT
Q_INTERFACES(ctkEventHandler)
public: public:
explicit FMPStartEventHandler(ctkPluginContext *ctx, FMPHome *home); explicit FMPStartEventHandler(ctkPluginContext *ctx, FMPHome *home);
void handleEvent(const ctkEvent &event); void handleEvent(const ctkEvent &event);
...@@ -29,8 +29,6 @@ public: ...@@ -29,8 +29,6 @@ public:
class FMPUpgradeAckEventHandler : FMPHomeEventHandler class FMPUpgradeAckEventHandler : FMPHomeEventHandler
{ {
Q_OBJECT
Q_INTERFACES(ctkEventHandler)
public: public:
explicit FMPUpgradeAckEventHandler(ctkPluginContext *ctx, FMPHome *home); explicit FMPUpgradeAckEventHandler(ctkPluginContext *ctx, FMPHome *home);
void handleEvent(const ctkEvent &event); void handleEvent(const ctkEvent &event);
......
...@@ -13,7 +13,11 @@ FMPHome::FMPHome(ctkPluginContext *context) ...@@ -13,7 +13,11 @@ FMPHome::FMPHome(ctkPluginContext *context)
FMPHome::~FMPHome() FMPHome::~FMPHome()
{ {
StopService(); StopService();
delete d_ptr;
if (d_ptr) {
delete d_ptr;
d_ptr = nullptr;
}
} }
void FMPHome::InitService() void FMPHome::InitService()
...@@ -22,7 +26,6 @@ void FMPHome::InitService() ...@@ -22,7 +26,6 @@ void FMPHome::InitService()
Q_D(FMPHome); Q_D(FMPHome);
d->Init(); d->Init();
} }
_semaphore.release(1);
} }
void FMPHome::UninitService() void FMPHome::UninitService()
...@@ -31,7 +34,6 @@ void FMPHome::UninitService() ...@@ -31,7 +34,6 @@ void FMPHome::UninitService()
Q_D(FMPHome); Q_D(FMPHome);
d->Uninit(); d->Uninit();
} }
_semaphore.release(1);
} }
int FMPHome::login() int FMPHome::login()
......
...@@ -7,16 +7,17 @@ ...@@ -7,16 +7,17 @@
class FMPHomeInterface : public QObject, public FMPluginInterface class FMPHomeInterface : public QObject, public FMPluginInterface
{ {
Q_OBJECT Q_OBJECT
Q_INTERFACES(FMPBaseInterface)
Q_INTERFACES(FMPluginInterface) Q_INTERFACES(FMPluginInterface)
public: public:
explicit FMPHomeInterface(ctkPluginContext *ctx) : FMPluginInterface(ctx) explicit FMPHomeInterface(ctkPluginContext *ctx) : FMPluginInterface(ctx)
{ {
connect(this, &FMPHomeInterface::TriggerInit, this, &FMPHomeInterface::InitService); connect(this, &FMPHomeInterface::TriggerInit, this, &FMPHomeInterface::OnTriggerInit);
connect(this, &FMPHomeInterface::TriggerUninit, this, &FMPHomeInterface::UninitService); connect(this, &FMPHomeInterface::TriggerUninit, this, &FMPHomeInterface::OnTriggerUninit);
} }
virtual int login() = 0; virtual int login() = 0;
virtual bool isLogined() = 0; virtual bool isLogined() = 0;
virtual QString userName() = 0; virtual QString userName() = 0;
/** /**
* Entry 插件不需要请求启动,直接执行 StartService 启动 * Entry 插件不需要请求启动,直接执行 StartService 启动
...@@ -24,7 +25,7 @@ public: ...@@ -24,7 +25,7 @@ public:
* @brief StartService * @brief StartService
* @return * @return
*/ */
virtual int StartService() virtual int StartService()
{ {
TriggerInit(); TriggerInit();
_semaphore.acquire(1); _semaphore.acquire(1);
...@@ -38,14 +39,14 @@ public: ...@@ -38,14 +39,14 @@ public:
* @param image 要闪烁的图片地址 * @param image 要闪烁的图片地址
* @return int 此闪烁的标识id,可调用stopBlink(int blinkId)结束此闪烁 * @return int 此闪烁的标识id,可调用stopBlink(int blinkId)结束此闪烁
*/ */
virtual int blink(FMPluginInterface *plugin, const QString &image) = 0; virtual int blink(FMPluginInterface *plugin, const QString &image) = 0;
/** /**
* @brief stopBlink * @brief stopBlink
* 结束某个闪烁 * 结束某个闪烁
* @param blinkId 创建blink时返回的闪烁标识id * @param blinkId 创建blink时返回的闪烁标识id
* @return bool 如果参数blinkId标识的闪烁不存在或已结束则返回false, 否则返回true * @return bool 如果参数blinkId标识的闪烁不存在或已结束则返回false, 否则返回true
*/ */
virtual bool stopBlink(int blinkId) = 0; virtual bool stopBlink(int blinkId) = 0;
/** /**
* @brief notification * @brief notification
...@@ -55,16 +56,16 @@ public: ...@@ -55,16 +56,16 @@ public:
* @param icon * @param icon
* @param mecs * @param mecs
*/ */
virtual void notification(const QString &msg, const QString &title = QString::fromLocal8Bit(FMP_APPNAME), virtual void notification(const QString &msg, const QString &title = QString::fromLocal8Bit(FMP_APPNAME),
QSystemTrayIcon::MessageIcon icon = QSystemTrayIcon::Information, int mecs = 1000) = 0; QSystemTrayIcon::MessageIcon icon = QSystemTrayIcon::Information, int mecs = 1000) = 0;
protected slots:
void InitService() = 0;
void UninitService() = 0;
signals: signals:
void TriggerInit(); void TriggerInit();
void TriggerUninit(); void TriggerUninit();
protected slots:
void OnTriggerInit() { FMPluginInterface::OnTriggerInit(); }
void OnTriggerUninit() { FMPluginInterface::OnTriggerUninit(); }
}; };
Q_DECLARE_INTERFACE(FMPHomeInterface, "com.fmp.home") Q_DECLARE_INTERFACE(FMPHomeInterface, "com.fmp.home")
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
#define VER_MINOR 1 #define VER_MINOR 1
#define VER_REVISION 0 #define VER_REVISION 0
#define VER_BUILD 7 #define VER_BUILD 8
//! Convert version numbers to string //! Convert version numbers to string
#define _STR(S) #S #define _STR(S) #S
......
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