mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-18 00:03:05 -04:00
Add method to force a detach for QgsSpatialIndex
Since the underlying libspatialindex is not thread safe on some platforms (e.g. Windows), manual calls to detach() must be made if a QgsSpatialIndex is to be accessed across multiple threads. Note that for platforms on which libspatialindex is thread safe, calling detach() has no effect and does not force the deep copy.
This commit is contained in:
parent
98d43ea4e8
commit
abcaba857f
@ -60,6 +60,20 @@ Copy constructor
|
||||
~QgsSpatialIndex();
|
||||
|
||||
|
||||
void detach();
|
||||
%Docstring
|
||||
Detaches the index, forcing a deep copy of the underlying
|
||||
spatial index data.
|
||||
|
||||
Since the underlying libspatialindex is not thread safe on some platforms (e.g. Windows),
|
||||
manual calls to detach() must be made if a QgsSpatialIndex is to be accessed across multiple threads.
|
||||
|
||||
Note that for platforms on which libspatialindex is thread safe, calling
|
||||
detach() has no effect and does not force the deep copy.
|
||||
|
||||
.. versionadded:: 3.0
|
||||
%End
|
||||
|
||||
|
||||
bool insertFeature( const QgsFeature &f );
|
||||
%Docstring
|
||||
|
@ -266,6 +266,14 @@ QgsSpatialIndex &QgsSpatialIndex::operator=( const QgsSpatialIndex &other )
|
||||
return *this;
|
||||
}
|
||||
|
||||
void QgsSpatialIndex::detach()
|
||||
{
|
||||
// libspatialindex is not thread safe on windows - so force the deep copy
|
||||
#if defined(Q_OS_WIN)
|
||||
d.detach();
|
||||
#endif
|
||||
}
|
||||
|
||||
SpatialIndex::Region QgsSpatialIndex::rectToRegion( const QgsRectangle &rect )
|
||||
{
|
||||
double pt1[2] = { rect.xMinimum(), rect.yMinimum() },
|
||||
|
@ -97,6 +97,20 @@ class CORE_EXPORT QgsSpatialIndex
|
||||
//! Implement assignment operator
|
||||
QgsSpatialIndex &operator=( const QgsSpatialIndex &other );
|
||||
|
||||
/**
|
||||
* Detaches the index, forcing a deep copy of the underlying
|
||||
* spatial index data.
|
||||
*
|
||||
* Since the underlying libspatialindex is not thread safe on some platforms (e.g. Windows),
|
||||
* manual calls to detach() must be made if a QgsSpatialIndex is to be accessed across multiple threads.
|
||||
*
|
||||
* Note that for platforms on which libspatialindex is thread safe, calling
|
||||
* detach() has no effect and does not force the deep copy.
|
||||
*
|
||||
* \since QGIS 3.0
|
||||
*/
|
||||
void detach();
|
||||
|
||||
/* operations */
|
||||
|
||||
//! Add feature to index
|
||||
|
Loading…
x
Reference in New Issue
Block a user