Skip to content

Commit

Permalink
fix duplicate when using static qgis_core lib
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterPetrik authored and nyalldawson committed Nov 24, 2020
1 parent 3b4e360 commit 0da839f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
12 changes: 6 additions & 6 deletions src/core/providers/ogr/qgsogrprovider.cpp
Expand Up @@ -7175,20 +7175,20 @@ QgsTransaction *QgsOgrProviderMetadata::createTransaction( const QString &connSt
return new QgsOgrTransaction( connString, ds );
}

QgsGeoPackageProjectStorage *gProjectStorage = nullptr; // when not null it is owned by QgsApplication::projectStorageRegistry()
QgsGeoPackageProjectStorage *gGeoPackageProjectStorage = nullptr; // when not null it is owned by QgsApplication::projectStorageRegistry()

void QgsOgrProviderMetadata::initProvider()
{
Q_ASSERT( !gProjectStorage );
gProjectStorage = new QgsGeoPackageProjectStorage;
QgsApplication::projectStorageRegistry()->registerProjectStorage( gProjectStorage ); // takes ownership
Q_ASSERT( !gGeoPackageProjectStorage );
gGeoPackageProjectStorage = new QgsGeoPackageProjectStorage;
QgsApplication::projectStorageRegistry()->registerProjectStorage( gGeoPackageProjectStorage ); // takes ownership
}


void QgsOgrProviderMetadata::cleanupProvider()
{
QgsApplication::projectStorageRegistry()->unregisterProjectStorage( gProjectStorage ); // destroys the object
gProjectStorage = nullptr;
QgsApplication::projectStorageRegistry()->unregisterProjectStorage( gGeoPackageProjectStorage ); // destroys the object
gGeoPackageProjectStorage = nullptr;
QgsOgrConnPool::cleanupInstance();
// NOTE: QgsApplication takes care of
// calling OGRCleanupAll();
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsvirtuallayerdefinition.cpp
Expand Up @@ -186,7 +186,7 @@ static inline ushort encodeNibble( ushort c )
return ushort( toHexUpper( c ) );
}

bool qt_is_ascii( const char *&ptr, const char *end ) noexcept
static bool qt_is_ascii( const char *&ptr, const char *end ) noexcept
{
while ( ptr + 4 <= end )
{
Expand Down
12 changes: 6 additions & 6 deletions src/providers/postgres/qgspostgresprovider.cpp
Expand Up @@ -5564,19 +5564,19 @@ QgsAbstractProviderConnection *QgsPostgresProviderMetadata::createConnection( co
}


QgsPostgresProjectStorage *gProjectStorage = nullptr; // when not null it is owned by QgsApplication::projectStorageRegistry()
QgsPostgresProjectStorage *gPgProjectStorage = nullptr; // when not null it is owned by QgsApplication::projectStorageRegistry()

void QgsPostgresProviderMetadata::initProvider()
{
Q_ASSERT( !gProjectStorage );
gProjectStorage = new QgsPostgresProjectStorage;
QgsApplication::projectStorageRegistry()->registerProjectStorage( gProjectStorage ); // takes ownership
Q_ASSERT( !gPgProjectStorage );
gPgProjectStorage = new QgsPostgresProjectStorage;
QgsApplication::projectStorageRegistry()->registerProjectStorage( gPgProjectStorage ); // takes ownership
}

void QgsPostgresProviderMetadata::cleanupProvider()
{
QgsApplication::projectStorageRegistry()->unregisterProjectStorage( gProjectStorage ); // destroys the object
gProjectStorage = nullptr;
QgsApplication::projectStorageRegistry()->unregisterProjectStorage( gPgProjectStorage ); // destroys the object
gPgProjectStorage = nullptr;

QgsPostgresConnPool::cleanupInstance();
}
Expand Down

0 comments on commit 0da839f

Please sign in to comment.