X-Git-Url: https://vaikene.ee/gitweb/pswgen11.html?a=blobdiff_plain;f=src%2Flibs%2FPlugins%2Fpluginmanager.cpp;h=21db40b018ba2e7f10f34a4d2c1a0b66a8eef175;hb=84f796df7f84e8e13efb68bbe1cb9f5c804c2228;hp=c357d114a3236b227ed0fd4cf05428a033c283f9;hpb=f26e65c1e66cf02eae9aa209acac743e3b04b4f4;p=evaf
diff --git a/src/libs/Plugins/pluginmanager.cpp b/src/libs/Plugins/pluginmanager.cpp
index c357d11..21db40b 100644
--- a/src/libs/Plugins/pluginmanager.cpp
+++ b/src/libs/Plugins/pluginmanager.cpp
@@ -25,7 +25,6 @@
#include
#include
#include
-#include
#include
#include
@@ -145,7 +144,7 @@ void PluginManagerPrivate::done()
bool PluginManagerPrivate::loadPlugins()
{
// Get the name of the application's XML file
- QString xmlFileName = Common::iEnv::instance()->etcDir() + Common::iApp::instance()->xmlFileName();
+ QString xmlFileName = Common::iApp::instance()->etcDir() + Common::iApp::instance()->xmlFileName();
// Open the XML file
QFile xmlFile(xmlFileName);
@@ -312,7 +311,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);
}
@@ -326,7 +325,7 @@ bool PluginManagerPrivate::loadPlugins()
void PluginManagerPrivate::unloadPlugins()
{
// Finalize all the plugins
- for (int i = 0; i < mPlugins.size(); ++i)
+ for (int i = mPlugins.size() - 1; i >= 0; --i)
mPlugins.at(i)->done();
while (!mPlugins.isEmpty()) {
QExplicitlySharedDataPointer p = mPlugins.takeLast();
@@ -355,18 +354,18 @@ bool PluginManagerPrivate::loadQtPlugin(QString const & name) const
QString fileName;
#ifdef Q_OS_LINUX
- fileName = QString("%1libq%2.so").arg(Common::iEnv::instance()->qtPluginsDir()).arg(name);
+ fileName = QString("%1libq%2.so").arg(Common::iApp::instance()->qtPluginsDir()).arg(name);
# ifndef QT_NO_DEBUG
- QString t = QString("%1libq%2.so.debug").arg(Common::iEnv::instance()->qtPluginsDir()).arg(name);
+ QString t = QString("%1libq%2.so.debug").arg(Common::iApp::instance()->qtPluginsDir()).arg(name);
if (QFile::exists(t))
fileName = t;
# endif
#endif
#ifdef Q_OS_WIN32
- fileName = QString("%2q%2%3").arg(Common::iEnv::instance()->qtPluginsDir()).arg(name).arg("4.dll");
+ fileName = QString("%1q%2%3").arg(Common::iApp::instance()->qtPluginsDir()).arg(name).arg("4.dll");
# ifndef QT_NO_DEBUG
- QString t = QString(%1q%2%3).arg(Common::iEnv::instance()->qtPluginsDir()).arg(name).arg(d4.dll);
+ QString t = QString("%1q%2%3").arg(Common::iApp::instance()->qtPluginsDir()).arg(name).arg("d4.dll");
if (!QFile::exists(t))
fileName = t;
# endif
@@ -405,16 +404,16 @@ Module::Module(QString const & name)
Module::~Module()
{
- if (mPluginFactory)
- delete mPluginFactory;
- if (mLoader)
+ if (mLoader) {
+ mLoader->unload();
delete mLoader;
+ }
}
bool Module::load()
{
// The real file name with path
- QString fileName = Common::iEnv::instance()->binDir() + expandPluginName(mName);
+ QString fileName = Common::iApp::instance()->binDir() + expandPluginName(mName);
// Try to load the module
QScopedPointer p(new QPluginLoader(fileName));
@@ -430,7 +429,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 +443,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;
}
@@ -461,7 +457,7 @@ iPlugin * Module::create(QString const & name)
// If the module is not loaded, load it now
if (!mLoader) {
if (!load())
- return false;
+ return 0;
}
iPlugin * i = 0;
@@ -509,8 +505,6 @@ Plugin::Plugin(Module * module, QString const & name, QString const & args)
Plugin::~Plugin()
{
- if (mPlugin)
- delete mPlugin;
}
bool Plugin::load()
@@ -523,10 +517,7 @@ bool Plugin::load()
void Plugin::unload()
{
- if (mPlugin) {
- delete mPlugin;
- mPlugin = 0;
- }
+ mPlugin = 0;
}
bool Plugin::init()