Skip to content
Permalink
Browse files

Fix crash on destruction of QgsPointLocator, if object is destroyed

while indexing is happening in the background
  • Loading branch information
nyalldawson committed Jan 28, 2020
1 parent 01d0c59 commit 08adb23a7ec284a2f84ecf7ac469fbe9004ab57e
Showing with 7 additions and 1 deletion.
  1. +6 −1 src/core/qgspointlocator.cpp
  2. +1 −0 src/core/qgspointlocator.h
@@ -549,6 +549,7 @@ QgsPointLocator::QgsPointLocator( QgsVectorLayer *layer, const QgsCoordinateRefe
QgsPointLocator::~QgsPointLocator()
{
// don't delete a locator if there is an indexing task running on it
mIsDestroying = true;
if ( mIsIndexing )
waitForIndexingFinished();

@@ -597,6 +598,9 @@ void QgsPointLocator::onInitTaskFinished()
if ( !mIsIndexing )
return;

if ( mIsDestroying )
return;

mIsIndexing = false;
mRenderer.reset();
mSource.reset();
@@ -652,7 +656,8 @@ void QgsPointLocator::waitForIndexingFinished()
{
mInitTask->waitForFinished();

onInitTaskFinished();
if ( !mIsDestroying )
onInitTaskFinished();
}

bool QgsPointLocator::hasIndex() const
@@ -389,6 +389,7 @@ class CORE_EXPORT QgsPointLocator : public QObject
std::unique_ptr<QgsVectorLayerFeatureSource> mSource;
int mMaxFeaturesToIndex = -1;
bool mIsIndexing = false;
bool mIsDestroying = false;
QgsFeatureIds mAddedFeatures;
QgsFeatureIds mDeletedFeatures;
QPointer<QgsPointLocatorInitTask> mInitTask;

0 comments on commit 08adb23

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