Skip to content
Permalink
Browse files
Call unload() on QGIS exit also for python plugins.
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@9511 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
wonder committed Oct 21, 2008
1 parent db03de5 commit 4c122065efd6666aac8e3156bd3cf03c1b8c1b3d
Showing with 41 additions and 12 deletions.
  1. +2 −0 src/app/qgisapp.cpp
  2. +25 −2 src/app/qgspluginregistry.cpp
  3. +14 −10 src/app/qgspluginregistry.h
@@ -4187,6 +4187,8 @@ void QgisApp::loadPythonSupport()

if ( mPythonUtils && mPythonUtils->isEnabled() )
{
QgsPluginRegistry::instance()->setPythonUtils(mPythonUtils);

mActionShowPythonDialog = new QAction( tr( "Python Console" ), this );
connect( mActionShowPythonDialog, SIGNAL( triggered() ), this, SLOT( showPythonDialog() ) );

@@ -20,6 +20,8 @@
#include "qgspluginregistry.h"
#include "qgspluginmetadata.h"
#include "qgisplugin.h"
#include "qgspythonutils.h"
#include "qgslogger.h"

QgsPluginRegistry *QgsPluginRegistry::_instance = 0;
QgsPluginRegistry *QgsPluginRegistry::instance()
@@ -32,9 +34,16 @@ QgsPluginRegistry *QgsPluginRegistry::instance()
}

QgsPluginRegistry::QgsPluginRegistry()
: mPythonUtils(NULL)
{
// constructor does nothing
}

void QgsPluginRegistry::setPythonUtils(QgsPythonUtils* pythonUtils)
{
mPythonUtils = pythonUtils;
}

QString QgsPluginRegistry::library( QString pluginKey )
{
QgsPluginMetadata *pmd = plugins[pluginKey];
@@ -92,6 +101,20 @@ void QgsPluginRegistry::unloadAll()
for ( std::map<QString, QgsPluginMetadata*>::iterator it = plugins.begin();
it != plugins.end();
it++ )
if ( it->second->plugin() )
it->second->plugin()->unload();
{
if (isPythonPlugin(it->second->name()))
{
if (mPythonUtils)
mPythonUtils->unloadPlugin(it->second->library());
else
QgsDebugMsg("warning: python utils is NULL");
}
else
{
if ( it->second->plugin() )
it->second->plugin()->unload();
else
QgsDebugMsg("warning: plugin is NULL:" + it->second->name());
}
}
}
@@ -21,6 +21,7 @@
#define QGSPLUGINREGISTRY_H
#include <map>
class QgsPluginMetadata;
class QgsPythonUtils;
class QgisPlugin;
class QString;
/**
@@ -31,29 +32,32 @@ class QString;
class QgsPluginRegistry
{
public:
//! Returns the instance pointer, creating the object on the first call
//! Returns the instance pointer, creating the object on the first call
static QgsPluginRegistry* instance();
//! Return the full path to the plugins library using the plugin name as a key
//! Return the full path to the plugins library using the plugin name as a key
QString library( QString pluginKey );
//! Retrieve the metadata for a plugin by name
//! Retrieve the metadata for a plugin by name
QgsPluginMetadata * pluginMetadata( QString name );
//! Retrieve a pointer to a loaded plugin by name
//! Retrieve a pointer to a loaded plugin by name
QgisPlugin * plugin( QString name );
//! Return whether the plugin is pythonic
//! Return whether the plugin is pythonic
bool isPythonPlugin( QString name );
//! Add a plugin to the map of loaded plugins
//! Add a plugin to the map of loaded plugins
void addPlugin( QString _library, QString _name, QgisPlugin * _plugin );
//! Add a plugin written in python
//! Add a plugin written in python
void addPythonPlugin( QString packageName, QString pluginName );
//! Remove a plugin from the list of loaded plugins
//! Remove a plugin from the list of loaded plugins
void removePlugin( QString name );
//! Unload plugins
//! Unload plugins
void unloadAll();
//! Save pointer for python utils (needed for unloading python plugins)
void setPythonUtils(QgsPythonUtils* pythonUtils);
protected:
//! protected constructor
//! protected constructor
QgsPluginRegistry();
private:
static QgsPluginRegistry* _instance;
std::map<QString, QgsPluginMetadata*> plugins;
QgsPythonUtils* mPythonUtils;
};
#endif //QgsPluginRegistry_H

0 comments on commit 4c12206

Please sign in to comment.