Skip to content
Permalink
Browse files
Added a wrapper for ogr register all so that it cant be called twice …
…(on suggestion of M. Loskot).

Fixes issues where drivers appear to be registered more than once.


git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@9195 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
timlinux committed Aug 27, 2008
1 parent df47953 commit d810ee0c2b214dcac689cf20acd8cdf1a1583613
@@ -191,5 +191,13 @@ static void qtgui_UpdatePyArgv(PyObject *argvlist, int argc, char **argv)
* application instance useful for debugging mainly.*/
static QString showSettings();

/** Register OGR drivers ensuring this only happens once.
* This is a workaround for an issue with older gdal versions that
* caused duplicate driver name entries to appear in the list
* of registered drivers when QgsApplication::registerOgrDrivers was called multiple
* times.
*/
static void registerOgrDrivers();

};

@@ -32,6 +32,8 @@
#include <netinet/in.h>
#endif

#include <ogr_api.h>

QString QgsApplication::mPrefixPath;
QString QgsApplication::mPluginPath;
QString QgsApplication::mPkgDataPath;
@@ -314,4 +316,10 @@ QString QgsApplication::reportStyleSheet()
return myStyle;
}


void QgsApplication::registerOgrDrivers()
{
if ( 0 >= OGRGetDriverCount() )
{
OGRRegisterAll();
}
}
@@ -139,6 +139,14 @@ class CORE_EXPORT QgsApplication: public QApplication
/** Convenience function to get a summary of the paths used in this
* application instance useful for debugging mainly.*/
static QString showSettings();
/** Register OGR drivers ensuring this only happens once.
* This is a workaround for an issue with older gdal versions that
* caused duplicate driver name entries to appear in the list
* of registered drivers when QgsApplication::registerOgrDrivers was called multiple
* times.
*/
static void registerOgrDrivers();

private:
static QString mPrefixPath;
static QString mPluginPath;
@@ -17,6 +17,7 @@
***************************************************************************/
/* $Id$ */

#include "qgsapplication.h"
#include "qgsfield.h"
#include "qgsfeature.h"
#include "qgsgeometry.h"
@@ -48,7 +49,7 @@ QgsVectorFileWriter::QgsVectorFileWriter( const QString& shapefileName,

// find driver in OGR
OGRSFDriverH poDriver;
OGRRegisterAll();
QgsApplication::registerOgrDrivers();
poDriver = OGRGetDriverByName( driverName.toLocal8Bit().data() );

if ( poDriver == NULL )

0 comments on commit d810ee0

Please sign in to comment.