[QGIS Commit] r9511 - trunk/qgis/src/app
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Tue Oct 21 13:54:10 EDT 2008
Author: wonder
Date: 2008-10-21 13:54:10 -0400 (Tue, 21 Oct 2008)
New Revision: 9511
Modified:
trunk/qgis/src/app/qgisapp.cpp
trunk/qgis/src/app/qgspluginregistry.cpp
trunk/qgis/src/app/qgspluginregistry.h
Log:
Call unload() on QGIS exit also for python plugins.
Modified: trunk/qgis/src/app/qgisapp.cpp
===================================================================
--- trunk/qgis/src/app/qgisapp.cpp 2008-10-21 17:35:13 UTC (rev 9510)
+++ trunk/qgis/src/app/qgisapp.cpp 2008-10-21 17:54:10 UTC (rev 9511)
@@ -4187,6 +4187,8 @@
if ( mPythonUtils && mPythonUtils->isEnabled() )
{
+ QgsPluginRegistry::instance()->setPythonUtils(mPythonUtils);
+
mActionShowPythonDialog = new QAction( tr( "Python Console" ), this );
connect( mActionShowPythonDialog, SIGNAL( triggered() ), this, SLOT( showPythonDialog() ) );
Modified: trunk/qgis/src/app/qgspluginregistry.cpp
===================================================================
--- trunk/qgis/src/app/qgspluginregistry.cpp 2008-10-21 17:35:13 UTC (rev 9510)
+++ trunk/qgis/src/app/qgspluginregistry.cpp 2008-10-21 17:54:10 UTC (rev 9511)
@@ -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()
+ : 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 @@
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());
+ }
+ }
}
Modified: trunk/qgis/src/app/qgspluginregistry.h
===================================================================
--- trunk/qgis/src/app/qgspluginregistry.h 2008-10-21 17:35:13 UTC (rev 9510)
+++ trunk/qgis/src/app/qgspluginregistry.h 2008-10-21 17:54:10 UTC (rev 9511)
@@ -21,6 +21,7 @@
#define QGSPLUGINREGISTRY_H
#include <map>
class QgsPluginMetadata;
+class QgsPythonUtils;
class QgisPlugin;
class QString;
/**
@@ -31,29 +32,32 @@
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
More information about the QGIS-commit
mailing list