Skip to content

Commit 296bfde

Browse files
committedJun 11, 2019
Don't create a provider registry instance only to delete it
Clears up more debugging noise in crssync
1 parent 5855204 commit 296bfde

File tree

4 files changed

+16
-3
lines changed

4 files changed

+16
-3
lines changed
 

‎src/core/qgsapplication.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1229,7 +1229,9 @@ void QgsApplication::exitQgis()
12291229

12301230
delete QgsProject::instance();
12311231

1232-
delete QgsProviderRegistry::instance();
1232+
// avoid creating instance just to delete it!
1233+
if ( QgsProviderRegistry::exists() )
1234+
delete QgsProviderRegistry::instance();
12331235

12341236
// invalidate coordinate cache while the PROJ context held by the thread-locale
12351237
// QgsProjContextStore object is still alive. Otherwise if this later object

‎src/core/qgscoordinatereferencesystem.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2901,8 +2901,7 @@ int QgsCoordinateReferenceSystem::syncDatabase()
29012901
return -1;
29022902
}
29032903

2904-
Q_UNUSED( deleted )
2905-
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 );
2904+
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 );
29062905

29072906
if ( errors > 0 )
29082907
return -errors;

‎src/core/qgsproviderregistry.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,11 @@ void QgsProviderRegistry::clean()
291291
mProviders.clear();
292292
}
293293

294+
bool QgsProviderRegistry::exists()
295+
{
296+
return static_cast< bool >( sInstance );
297+
}
298+
294299
QgsProviderRegistry::~QgsProviderRegistry()
295300
{
296301
clean();

‎src/core/qgsproviderregistry.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,13 @@ class CORE_EXPORT QgsProviderRegistry
296296
*/
297297
QString mProtocolDrivers;
298298

299+
/**
300+
* Returns TRUE if registry instance exists.
301+
*/
302+
static bool exists();
303+
304+
friend class QgsApplication;
305+
299306
}; // class QgsProviderRegistry
300307

301308
#endif //QGSPROVIDERREGISTRY_H

0 commit comments

Comments
 (0)
Please sign in to comment.