Commit 4049a277 by Carwyn

1. 解决业务插件在主线程调用停止服务卡死问题; 2. 所有插件在析构中调用停止服务接口; 3. 按加载顺序停止服务; 4. 其他

parent 62334778
......@@ -10,6 +10,7 @@ SUBDIRS += fmp_manager \
fmp_epay \
fmp_home \
fmp_vip \
fmp_takeout \
FreemudPOS \
FreemudSyncer
......
fmp_epay @ cdcd1627
Subproject commit 6aa8b2c2dc029b9701ea0b48007da4cbb33c337c
Subproject commit cdcd1627794832dc0cb7ea0610430b38af72c3d5
fmp_home @ acf4517e
Subproject commit 32832ecf4e867225508226eeb201d62b698540a6
Subproject commit acf4517e2b033d0f1a00ef6e46dab415a28f1feb
......@@ -36,7 +36,12 @@ FMPLogger::FMPLogger(ctkPluginContext *context)
FMPLogger::~FMPLogger()
{
StopService();
if (d_ptr) {
delete d_ptr;
d_ptr = nullptr;
}
}
void FMPLogger::InitService()
......
......@@ -42,10 +42,12 @@ int FMPLoggerPrivate::Uninit()
Q_Q(FMPLogger);
//! Clean up
if (q->_file) {
q->_file->close();
_inited = false;
delete q->_file;
q->_file = 0;
}
_inited = false;
return FMP_SUCCESS;
}
......
......@@ -5,7 +5,7 @@
#define VER_MINOR 1
#define VER_REVISION 0
#define VER_BUILD 45
#define VER_BUILD 51
//! Convert version numbers to string
#define _STR(S) #S
......
......@@ -102,20 +102,25 @@ void FMPluginManager::UninitService()
FMP_INFO() << "======================== Quit ========================";
_watcher.removePath(_fw_props[FMP_PROPKEY_PLUGINPATH].toString());
FMPLoggerInterface::InitContext(_ctx, false);
//! TODO: 优雅关闭
// try {
// _fw->stop();
// do {
// QCoreApplication::processEvents();
// } while(_fw->waitForStop(50).getType() == ctkPluginFrameworkEvent::FRAMEWORK_WAIT_TIMEDOUT);
// }
// catch (const ctkPluginException& e) {
// FMP_ERROR() << e.cause()->what();
// }
// delete _fw_factory;
//! 优雅关闭
while(!_plugins.isEmpty()) {
_plugins.pop()->stop();
}
try {
_fw->stop();
int cnt = 0;
while(cnt++ < 10 &&
_fw->waitForStop(50).getType() == ctkPluginFrameworkEvent::FRAMEWORK_WAIT_TIMEDOUT) {
QCoreApplication::processEvents();
}
}
catch (const ctkPluginException &e) {
FMP_DEBUG() << e.cause()->what();
}
delete _fw_factory;
_fw_factory = nullptr;
// _ctx = nullptr;
_ctx = nullptr;
_fw.clear();
_event_handlers.clear();
......@@ -162,6 +167,7 @@ int FMPluginManager::LoadPlugin(const QString &plugin)
QSharedPointer<ctkPlugin> p = pc->installPlugin(QUrl::fromLocalFile(plugin_info.canonicalFilePath()));
if (!p.isNull()) {
p->start(ctkPlugin::START_TRANSIENT);
_plugins << p;
}
}
else {
......
......@@ -2,6 +2,7 @@
#define FMPLUGINMANAGER_H
#include <QObject>
#include <QStack>
#include <QFileInfo>
#include <QFileSystemWatcher>
#include "fmp_manager_i.h"
......@@ -30,7 +31,7 @@ class FMPluginManager : public QObject, FMPManagerInterface
public:
explicit FMPluginManager();
~FMPluginManager();
virtual ~FMPluginManager();
protected:
//! 基础接口
......@@ -77,6 +78,7 @@ private:
FMPSyncerInterface *_syncer;
FMPEventHandlerList _event_handlers;
QStack<QSharedPointer<ctkPlugin> > _plugins;
};
#endif // FMPLUGINMANAGER_H
......@@ -5,7 +5,7 @@
#define VER_MINOR 1
#define VER_REVISION 0
#define VER_BUILD 45
#define VER_BUILD 51
//! Convert version numbers to string
#define _STR(S) #S
......
......@@ -5,7 +5,7 @@
#define VER_MINOR 1
#define VER_REVISION 0
#define VER_BUILD 45
#define VER_BUILD 51
//! Convert version numbers to string
#define _STR(S) #S
......
fmp_settings @ ad13983a
Subproject commit 770b2d40f58b0dd33830d7a6db40a956f5718ae1
Subproject commit ad13983a4b3d985172e888a3fd4eb0e72794cae1
......@@ -23,6 +23,11 @@ FMPSyncer::FMPSyncer(ctkPluginContext *ctx)
FMPSyncer::~FMPSyncer()
{
StopService();
if (d_ptr) {
delete d_ptr;
d_ptr = nullptr;
}
}
void FMPSyncer::InitService()
......
......@@ -5,7 +5,7 @@
#define VER_MINOR 1
#define VER_REVISION 0
#define VER_BUILD 45
#define VER_BUILD 51
//! Convert version numbers to string
#define _STR(S) #S
......
fmp_takeout @ 6f71ce4d
Subproject commit b7dc6d93703aa56de6783892cbd903704f3febe3
Subproject commit 6f71ce4db37ac79379b9dd532bfe2e1a15c04474
fmp_vip @ 2f19af5a
Subproject commit 277592473adac876e72671fbf27a5007ea289e20
Subproject commit 2f19af5a9ca995852b3762b8cbdd6a24da6cc999
......@@ -50,6 +50,19 @@ public:
protected:
virtual void TriggerInit() = 0;
virtual void TriggerUninit() = 0;
virtual void OnTriggerInit()
{
InitService();
_semaphore.release(1);
}
virtual void OnTriggerUninit()
{
UninitService();
_semaphore.release(1);
}
int PostEvent(const QString &topic, const FMPProps &pps = FMPProps())
{
ctkEventAdmin *event_admin = GetService<ctkEventAdmin>(_ctx);
......
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