Skip to content
Permalink
Browse files

Use PJ_CONTEXT* instead of void*

(cherry picked from commit aa5ae9e)
  • Loading branch information
nyalldawson committed Jan 21, 2020
1 parent f41076d commit c1ad28e75972080f0136b4a0c18c685c4732f7d9
@@ -690,7 +690,7 @@ bool QgsCoordinateReferenceSystem::loadFromDatabase( const QString &db, const QS
}

#if PROJ_VERSION_MAJOR>=6
void QgsCoordinateReferenceSystem::removeFromCacheObjectsBelongingToCurrentThread( void *pj_context )
void QgsCoordinateReferenceSystem::removeFromCacheObjectsBelongingToCurrentThread( PJ_CONTEXT *pj_context )
{
// Not completely sure about object order destruction after main() has
// exited. So it is safer to check sDisableCache before using sCacheLock
@@ -44,6 +44,10 @@ class QgsCoordinateReferenceSystemPrivate;
#ifndef SIP_RUN
struct PJconsts;
typedef struct PJconsts PJ;

struct projCtx_t;
typedef struct projCtx_t PJ_CONTEXT;

#endif
#endif

@@ -960,7 +964,7 @@ class CORE_EXPORT QgsCoordinateReferenceSystem
friend class QgsProjContext;

// Only meant to be called by QgsProjContext::~QgsProjContext()
static void removeFromCacheObjectsBelongingToCurrentThread( void *pj_context );
static void removeFromCacheObjectsBelongingToCurrentThread( PJ_CONTEXT *pj_context );
#endif

//! Function for CRS validation. May be NULLPTR.
@@ -155,7 +155,7 @@ class QgsCoordinateReferenceSystemPrivate : public QSharedData

#if PROJ_VERSION_MAJOR>=6
mutable QReadWriteLock mProjLock;
mutable QMap < uintptr_t, PJ * > mProjObjects;
mutable QMap < PJ_CONTEXT *, PJ * > mProjObjects;

PJ *threadLocalProjObject() const
{
@@ -164,7 +164,7 @@ class QgsCoordinateReferenceSystemPrivate : public QSharedData
return nullptr;

PJ_CONTEXT *context = QgsProjContext::get();
QMap < uintptr_t, PJ * >::const_iterator it = mProjObjects.constFind( reinterpret_cast< uintptr_t>( context ) );
QMap < PJ_CONTEXT *, PJ * >::const_iterator it = mProjObjects.constFind( context );

if ( it != mProjObjects.constEnd() )
{
@@ -175,16 +175,16 @@ class QgsCoordinateReferenceSystemPrivate : public QSharedData
locker.changeMode( QgsReadWriteLocker::Write );

PJ *res = proj_clone( context, mPj.get() );
mProjObjects.insert( reinterpret_cast< uintptr_t>( context ), res );
mProjObjects.insert( context, res );
return res;
}

// Only meant to be called by QgsCoordinateReferenceSystem::removeFromCacheObjectsBelongingToCurrentThread()
bool removeObjectsBelongingToCurrentThread( void *pj_context )
bool removeObjectsBelongingToCurrentThread( PJ_CONTEXT *pj_context )
{
QgsReadWriteLocker locker( mProjLock, QgsReadWriteLocker::Write );

QMap < uintptr_t, PJ * >::iterator it = mProjObjects.find( reinterpret_cast< uintptr_t>( pj_context ) );
QMap < PJ_CONTEXT *, PJ * >::iterator it = mProjObjects.find( pj_context );
if ( it != mProjObjects.end() )
{
proj_destroy( it.value() );

0 comments on commit c1ad28e

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