Skip to content
Permalink
Browse files

Use a temporary PJ_CONTEXT when destroying PJ objects, just in case t…

…he owner context has since been deleted

(cherry picked from commit 9dcb74d)
  • Loading branch information
nyalldawson committed Jan 21, 2020
1 parent c1ad28e commit c1c6ef207e4405efaf48a83cafe236593d572d33
Showing with 13 additions and 0 deletions.
  1. +13 −0 src/core/qgscoordinatereferencesystem_p.h
@@ -98,11 +98,24 @@ class QgsCoordinateReferenceSystemPrivate : public QSharedData
#if PROJ_VERSION_MAJOR>=6
QgsReadWriteLocker locker( mProjLock, QgsReadWriteLocker::Write );

// During destruction of PJ* objects, the errno is set in the underlying
// context. Consequently the context attached to the PJ* must still exist !
// Which is not necessarily the case currently unfortunately. So
// create a temporary dummy context, and attach it to the PJ* before destroying
// it
PJ_CONTEXT *tmpContext = proj_context_create();
for ( auto it = mProjObjects.begin(); it != mProjObjects.end(); ++it )
{
proj_assign_context( it.value(), tmpContext );
proj_destroy( it.value() );
}
mProjObjects.clear();
if ( mPj )
{
proj_assign_context( mPj.get(), tmpContext );
mPj.reset();
}
proj_context_destroy( tmpContext );
#else
OSRDestroySpatialReference( mCRS );
#endif

0 comments on commit c1c6ef2

Please sign in to comment.
You can’t perform that action at this time.