Skip to content

Commit

Permalink
Merge pull request #51405 from qgis/backport-51400-to-release-3_28
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Jan 9, 2023
2 parents bdf524b + 447b782 commit 9862c21
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/core/qgsapplication.cpp
Expand Up @@ -1495,8 +1495,6 @@ void QgsApplication::exitQgis()
delete sAuthManager;

//Ensure that all remaining deleteLater QObjects are actually deleted before we exit.
//This isn't strictly necessary (since we're exiting anyway) but doing so prevents a lot of
//LeakSanitiser noise which hides real issues
QgsApplication::sendPostedEvents( nullptr, QEvent::DeferredDelete );

//delete all registered functions from expression engine (see above comment)
Expand All @@ -1506,6 +1504,13 @@ void QgsApplication::exitQgis()
if ( QgsProject::sProject )
delete QgsProject::instance();

//Ensure that providers/layers which called deleteLater on objects as part of their cleanup
//result in fully deleted objects before we do the provider registry cleanup.
//E.g. the QgsOgrConnPool instance has deleteLater calls when unrefing layers, so clearing
//the project above has not yet fully cleaned up OGR objects, which we MUST do before
//cleaning up the provider
QgsApplication::sendPostedEvents( nullptr, QEvent::DeferredDelete );

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

0 comments on commit 9862c21

Please sign in to comment.