Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Also invalid QgsCoordinateReferenceSystem cache on qgis exit, fixes c…
…rashes on exit
  • Loading branch information
nyalldawson committed May 22, 2019
1 parent 810b522 commit 89d879c
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/core/qgsapplication.cpp
Expand Up @@ -315,6 +315,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 @@ -1203,6 +1213,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 89d879c

Please sign in to comment.