Skip to content

Commit c16a98d

Browse files
committedMay 24, 2019
Also invalid QgsCoordinateReferenceSystem cache on qgis exit, fixes crashes on exit
1 parent 888f34d commit c16a98d

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed
 

‎src/core/qgsapplication.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,16 @@ QgsApplication::~QgsApplication()
306306
delete mApplicationMembers;
307307
delete mQgisTranslator;
308308
delete mQtTranslator;
309+
310+
// invalidate coordinate cache while the PROJ context held by the thread-locale
311+
// QgsProjContextStore object is still alive. Otherwise if this later object
312+
// is destroyed before the static variables of the cache, we might use freed memory.
313+
314+
// we do this here as well as in exitQgis() -- it's safe to call as often as we want,
315+
// and there's just a *chance* that in between an exitQgis call and this destructor
316+
// something else's destructor has caused a new entry in the caches...
317+
QgsCoordinateTransform::invalidateCache();
318+
QgsCoordinateReferenceSystem::invalidateCache();
309319
}
310320

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

11941205
QgsStyle::cleanDefaultStyle();
11951206

0 commit comments

Comments
 (0)
Please sign in to comment.