Skip to content

Commit

Permalink
Use PJ_CONTEXT* instead of void*
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Jan 22, 2020
1 parent 8a71091 commit 2bf0e9f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/core/qgscoordinatereferencesystem.cpp
Expand Up @@ -693,7 +693,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
Expand Down
6 changes: 5 additions & 1 deletion src/core/qgscoordinatereferencesystem.h
Expand Up @@ -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

Expand Down Expand Up @@ -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.
Expand Down
10 changes: 5 additions & 5 deletions src/core/qgscoordinatereferencesystem_p.h
Expand Up @@ -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
{
Expand All @@ -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() )
{
Expand All @@ -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() );
Expand Down

0 comments on commit 2bf0e9f

Please sign in to comment.