mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-06 00:07:29 -04:00
Use QThreadStorage for GEOS context on windows
This commit is contained in:
parent
3d31ba4d39
commit
018c844828
@ -98,7 +98,12 @@ static void printGEOSNotice( const char *fmt, ... )
|
||||
// QgsGeosContext
|
||||
//
|
||||
|
||||
#if defined(USE_THREAD_LOCAL) && !defined(Q_OS_WIN)
|
||||
thread_local QgsGeosContext QgsGeosContext::sGeosContext;
|
||||
#else
|
||||
QThreadStorage< QgsGeosContext * > QgsGeosContext::sGeosContext;
|
||||
#endif
|
||||
|
||||
|
||||
QgsGeosContext::QgsGeosContext()
|
||||
{
|
||||
@ -122,7 +127,21 @@ QgsGeosContext::~QgsGeosContext()
|
||||
|
||||
GEOSContextHandle_t QgsGeosContext::get()
|
||||
{
|
||||
#if defined(USE_THREAD_LOCAL) && !defined(Q_OS_WIN)
|
||||
return sGeosContext.mContext;
|
||||
#else
|
||||
GEOSContextHandle_t gContext = nullptr;
|
||||
if ( sGeosContext.hasLocalData() )
|
||||
{
|
||||
gContext = sGeosContext.localData()->mContext;
|
||||
}
|
||||
else
|
||||
{
|
||||
sGeosContext.setLocalData( new QgsGeosContext() );
|
||||
gContext = sGeosContext.localData()->mContext;
|
||||
}
|
||||
return gContext;
|
||||
#endif
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -21,6 +21,7 @@ email : marco.hugentobler at sourcepole dot com
|
||||
#include "qgis_core.h"
|
||||
#include "qgsgeometryengine.h"
|
||||
#include "qgsgeometry.h"
|
||||
#include "qgsconfig.h"
|
||||
#include <geos_c.h>
|
||||
|
||||
class QgsLineString;
|
||||
@ -28,6 +29,9 @@ class QgsPolygon;
|
||||
class QgsGeometry;
|
||||
class QgsGeometryCollection;
|
||||
|
||||
#if !defined(USE_THREAD_LOCAL) || defined(Q_OS_WIN)
|
||||
#include <QThreadStorage>
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \class QgsGeosContext
|
||||
@ -55,7 +59,12 @@ class CORE_EXPORT QgsGeosContext
|
||||
* Thread local GEOS context storage. A new GEOS context will be created
|
||||
* for every thread.
|
||||
*/
|
||||
|
||||
#if defined(USE_THREAD_LOCAL) && !defined(Q_OS_WIN)
|
||||
static thread_local QgsGeosContext sGeosContext;
|
||||
#else
|
||||
static QThreadStorage< QgsGeosContext * > sGeosContext;
|
||||
#endif
|
||||
};
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user