Skip to content

Commit

Permalink
Also invalid QgsCoordinateReferenceSystem cache on qgis exit, fixes c…
Browse files Browse the repository at this point in the history
…rashes on exit
  • Loading branch information
nyalldawson committed May 24, 2019
1 parent 888f34d commit c16a98d
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/core/qgsapplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,16 @@ QgsApplication::~QgsApplication()
delete mApplicationMembers;
delete mQgisTranslator;
delete mQtTranslator;

// invalidate coordinate cache while the PROJ context held by the thread-locale
// QgsProjContextStore object is still alive. Otherwise if this later object
// is destroyed before the static variables of the cache, we might use freed memory.

// we do this here as well as in exitQgis() -- it's safe to call as often as we want,
// and there's just a *chance* that in between an exitQgis call and this destructor
// something else's destructor has caused a new entry in the caches...
QgsCoordinateTransform::invalidateCache();
QgsCoordinateReferenceSystem::invalidateCache();
}

QgsApplication *QgsApplication::instance()
Expand Down Expand Up @@ -1190,6 +1200,7 @@ void QgsApplication::exitQgis()
// QgsProjContextStore object is still alive. Otherwise if this later object
// is destroyed before the static variables of the cache, we might use freed memory.
QgsCoordinateTransform::invalidateCache();
QgsCoordinateReferenceSystem::invalidateCache();

QgsStyle::cleanDefaultStyle();

Expand Down

0 comments on commit c16a98d

Please sign in to comment.