Skip to content

Commit

Permalink
Fix segfault on cleanup of qgis_process command
Browse files Browse the repository at this point in the history
Fixes #51383
  • Loading branch information
nyalldawson authored and github-actions[bot] committed Jan 9, 2023
1 parent 40b975a commit adea97c
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/core/qgsapplication.cpp
Expand Up @@ -1418,15 +1418,20 @@ 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)
QgsExpression::cleanRegisteredFunctions();

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 adea97c

Please sign in to comment.