Skip to content

Commit

Permalink
Cleanup methods for providers (implemented for GDAL and OGR)
Browse files Browse the repository at this point in the history
Fix #8932
  • Loading branch information
m-kuhn committed Dec 5, 2013
1 parent 0bfc766 commit f2fbb2f
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/core/qgsproviderregistry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,25 @@ QgsProviderRegistry::QgsProviderRegistry( QString pluginPath )
} // QgsProviderRegistry ctor


// typedef for the unload dataprovider function
typedef void cleanupProviderFunction_t();

QgsProviderRegistry::~QgsProviderRegistry()
{
Providers::const_iterator it = mProviders.begin();

while ( it != mProviders.end() )
{
QString lib = it->second->library();
QLibrary myLib( lib );
if ( myLib.isLoaded() )
{
cleanupProviderFunction_t* cleanupFunc = ( cleanupProviderFunction_t* ) cast_to_fptr( myLib.resolve( "cleanupProvider" ) );
if ( cleanupFunc )
cleanupFunc();
}
it++;
}
}


Expand Down Expand Up @@ -292,7 +309,6 @@ QDir const & QgsProviderRegistry::libraryDirectory() const
typedef QgsDataProvider * classFactoryFunction_t( const QString * );



/** Copied from QgsVectorLayer::setDataProvider
* TODO: Make it work in the generic environment
*
Expand Down
5 changes: 5 additions & 0 deletions src/providers/gdal/qgsgdalprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2767,3 +2767,8 @@ QGISEXTERN QList<QPair<QString, QString> > *pyramidResamplingMethods()

return &methods;
}

QGISEXTERN void cleanupProvider()
{
GDALDestroyDriverManager();
}
4 changes: 4 additions & 0 deletions src/providers/ogr/qgsogrprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2456,3 +2456,7 @@ QGISEXTERN QgsVectorLayerImport::ImportError createEmptyLayer(
);
}

QGISEXTERN void cleanupProvider()
{
OGRCleanupAll();
}

0 comments on commit f2fbb2f

Please sign in to comment.