Skip to content

Commit

Permalink
Don't create a provider registry instance only to delete it
Browse files Browse the repository at this point in the history
Clears up more debugging noise in crssync
  • Loading branch information
nyalldawson committed Jun 11, 2019
1 parent 5855204 commit 296bfde
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/core/qgsapplication.cpp
Expand Up @@ -1229,7 +1229,9 @@ void QgsApplication::exitQgis()

delete QgsProject::instance();

delete QgsProviderRegistry::instance();
// avoid creating instance just to delete it!
if ( QgsProviderRegistry::exists() )
delete QgsProviderRegistry::instance();

// invalidate coordinate cache while the PROJ context held by the thread-locale
// QgsProjContextStore object is still alive. Otherwise if this later object
Expand Down
3 changes: 1 addition & 2 deletions src/core/qgscoordinatereferencesystem.cpp
Expand Up @@ -2901,8 +2901,7 @@ int QgsCoordinateReferenceSystem::syncDatabase()
return -1;
}

Q_UNUSED( deleted )
QgsDebugMsgLevel( QStringLiteral( "CRS update (inserted:%1 updated:%2 deleted:%3 errors:%4)" ).arg( QString::number( inserted ), QString::number( updated ), QString::number( deleted ), QString::number( errors ) ), 0 );
QgsDebugMsgLevel( QStringLiteral( "CRS update (inserted:%1 updated:%2 deleted:%3 errors:%4)" ).arg( QString::number( inserted ), QString::number( updated ), QString::number( deleted ), QString::number( errors ) ), 4 );

if ( errors > 0 )
return -errors;
Expand Down
5 changes: 5 additions & 0 deletions src/core/qgsproviderregistry.cpp
Expand Up @@ -291,6 +291,11 @@ void QgsProviderRegistry::clean()
mProviders.clear();
}

bool QgsProviderRegistry::exists()
{
return static_cast< bool >( sInstance );
}

QgsProviderRegistry::~QgsProviderRegistry()
{
clean();
Expand Down
7 changes: 7 additions & 0 deletions src/core/qgsproviderregistry.h
Expand Up @@ -296,6 +296,13 @@ class CORE_EXPORT QgsProviderRegistry
*/
QString mProtocolDrivers;

/**
* Returns TRUE if registry instance exists.
*/
static bool exists();

friend class QgsApplication;

}; // class QgsProviderRegistry

#endif //QGSPROVIDERREGISTRY_H
Expand Down

0 comments on commit 296bfde

Please sign in to comment.