Don't delete locator while indexing

This commit is contained in:
Julien Cabieces 2019-10-30 11:06:14 +01:00
parent d0e26fb3bc
commit 95a100bcc4
2 changed files with 14 additions and 0 deletions

View File

@ -548,6 +548,10 @@ QgsPointLocator::QgsPointLocator( QgsVectorLayer *layer, const QgsCoordinateRefe
QgsPointLocator::~QgsPointLocator()
{
// don't delete a locator if there is an indexing task running on it
if ( mIsIndexing )
waitForIndexingFinished();
destroyIndex();
}

View File

@ -464,6 +464,16 @@ class TestQgsPointLocator : public QObject
QCOMPARE( m.vertexIndex(), 2 );
}
void testDeleteLocator()
{
QgsPointLocator *loc = new QgsPointLocator( mVL, QgsCoordinateReferenceSystem(), QgsCoordinateTransformContext(), nullptr );
QgsPointXY pt( 2, 2 );
// delete locator while we are indexing (could happend when closing project for instance)
loc->nearestVertex( pt, 999, nullptr, true );
delete loc;
}
};
QGSTEST_MAIN( TestQgsPointLocator )