From: Enar Väikene Date: Wed, 18 May 2011 12:22:51 +0000 (+0300) Subject: Fixed Plugin manager. X-Git-Url: https://vaikene.ee/gitweb/pswgen11.html?a=commitdiff_plain;h=ad3c375c68b46edcb823ff3eb2dc12647da1db19;p=evaf Fixed Plugin manager. * Plugin manager now deletes only root components from external modules. Any iPlugin interface objects created using the iPluginFactory interface shall now be deleted by the external module. --- diff --git a/src/libs/Plugins/iPluginFactory b/src/libs/Plugins/iPluginFactory new file mode 100644 index 0000000..f40b04a --- /dev/null +++ b/src/libs/Plugins/iPluginFactory @@ -0,0 +1 @@ +#include "ipluginfactory.h" diff --git a/src/libs/Plugins/pluginmanager.cpp b/src/libs/Plugins/pluginmanager.cpp index c357d11..8ca6048 100644 --- a/src/libs/Plugins/pluginmanager.cpp +++ b/src/libs/Plugins/pluginmanager.cpp @@ -312,7 +312,7 @@ bool PluginManagerPrivate::loadPlugins() // Initialize eVaf plugins i = 0; while (i < mPlugins.size()) { - if (mPlugins.at(i)->init()) { + if (!mPlugins.at(i)->init()) { EVAF_ERROR("Failed to initialize module '%s'", qPrintable(mPlugins.at(i)->name())); mPlugins.removeAt(i); } @@ -405,10 +405,10 @@ Module::Module(QString const & name) Module::~Module() { - if (mPluginFactory) - delete mPluginFactory; - if (mLoader) + if (mLoader) { + mLoader->unload(); delete mLoader; + } } bool Module::load() @@ -430,7 +430,7 @@ bool Module::load() if ((mPluginFactory = qobject_cast(root)) == 0) { // If not, then it has to implement the iPlugin interface - if ((mPlugin = qobject_cast(root)) == 0) { + if (qobject_cast(root) == 0) { EVAF_FATAL_ERROR("Module '%s' is not a valid eVaf module", qPrintable(mName)); return false; } @@ -444,13 +444,10 @@ bool Module::load() void Module::unload() { mRoot = 0; - - if (mPluginFactory) { - delete mPluginFactory; - mPluginFactory = 0; - } + mPluginFactory = 0; mPlugin = 0; if (mLoader) { + mLoader->unload(); delete mLoader; mLoader = 0; } @@ -509,8 +506,6 @@ Plugin::Plugin(Module * module, QString const & name, QString const & args) Plugin::~Plugin() { - if (mPlugin) - delete mPlugin; } bool Plugin::load() @@ -523,10 +518,7 @@ bool Plugin::load() void Plugin::unload() { - if (mPlugin) { - delete mPlugin; - mPlugin = 0; - } + mPlugin = 0; } bool Plugin::init() diff --git a/src/libs/Plugins/version.h b/src/libs/Plugins/version.h index f114e5a..e3f4275 100644 --- a/src/libs/Plugins/version.h +++ b/src/libs/Plugins/version.h @@ -25,12 +25,12 @@ /** * Module/library version number in the form major,minor,release,build */ -#define VER_FILE_VERSION 0,1,1,1 +#define VER_FILE_VERSION 0,1,1,2 /** * Module/library version number in the string format (shall end with \0) */ -#define VER_FILE_VERSION_STR "0.1.1.1\0" +#define VER_FILE_VERSION_STR "0.1.1.2\0" /** * Module/library name (shall end with \0)