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
  • Loading branch information
nyalldawson committed Jan 21, 2020
1 parent 2bf0e9f commit e60d0ac2687417fedcced9cb6b98235b3ef662a5
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 e60d0ac

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