Navigation Menu

Skip to content

Commit

Permalink
Fix crash on destruction of QgsPointLocator, if object is destroyed
Browse files Browse the repository at this point in the history
while indexing is happening in the background
  • Loading branch information
nyalldawson committed Jan 28, 2020
1 parent 01d0c59 commit 08adb23
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/core/qgspointlocator.cpp
Expand Up @@ -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();

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

if ( mIsDestroying )
return;

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

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

bool QgsPointLocator::hasIndex() const
Expand Down
1 change: 1 addition & 0 deletions src/core/qgspointlocator.h
Expand Up @@ -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;
Expand Down

0 comments on commit 08adb23

Please sign in to comment.