Skip to content

Commit 287590e

Browse files
committed
Fix concurrency issue in snap indexing
1 parent 8a949fa commit 287590e

3 files changed

Lines changed: 11 additions & 2 deletions

File tree

‎qgis-test-travis.ctest‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,14 @@ ENDIF(NOT ${BUILDRES} EQUAL 0 OR NOT ${NUMERR} EQUAL 0)
6969
IF(NOT ${NUMWARN} EQUAL 0)
7070
ctest_submit (RETRY_COUNT 3 RETRY_DELAY 30)
7171
MESSAGE("${Yellow}Test results submitted to${ColorReset}")
72-
MESSAGE("${BoldYellow}${SHORTURL}{ColorReset}" )
72+
MESSAGE("${BoldYellow}${SHORTURL}${ColorReset}" )
7373
MESSAGE( FATAL_ERROR "${Red}Build warnings found, aborting test.${ColorReset}" )
7474
ENDIF(NOT ${NUMWARN} EQUAL 0)
7575
ctest_test (BUILD "${CTEST_BINARY_DIRECTORY}" PARALLEL_LEVEL 2 RETURN_VALUE TESTRES)
7676
IF(NOT ${TESTRES} EQUAL 0)
7777
ctest_submit (RETRY_COUNT 3 RETRY_DELAY 30)
7878
MESSAGE("${Yellow}Test results submitted to${ColorReset}")
79-
MESSAGE("${BoldYellow}${SHORTURL}{ColorReset}" )
79+
MESSAGE("${BoldYellow}${SHORTURL}${ColorReset}" )
8080
MESSAGE( FATAL_ERROR "Tests failed" )
8181
ENDIF(NOT ${TESTRES} EQUAL 0)
8282

‎src/core/qgssnappingutils.cpp‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ QgsSnappingUtils::QgsSnappingUtils( QObject* parent )
3030
, mDefaultTolerance( 10 )
3131
, mDefaultUnit( QgsTolerance::Pixels )
3232
, mSnapOnIntersection( false )
33+
, mIsIndexing( false )
3334
{
3435
connect( QgsMapLayerRegistry::instance(), SIGNAL( layersWillBeRemoved( QStringList ) ), this, SLOT( onLayersWillBeRemoved( QStringList ) ) );
3536
}
@@ -306,6 +307,10 @@ QgsPointLocator::Match QgsSnappingUtils::snapToMap( const QgsPoint& pointMap, Qg
306307

307308
void QgsSnappingUtils::prepareIndex( const QList<QgsVectorLayer*>& layers )
308309
{
310+
if ( mIsIndexing )
311+
return;
312+
mIsIndexing = true;
313+
309314
// check if we need to build any index
310315
QList<QgsVectorLayer*> layersToIndex;
311316
Q_FOREACH ( QgsVectorLayer* vl, layers )
@@ -329,6 +334,7 @@ void QgsSnappingUtils::prepareIndex( const QList<QgsVectorLayer*>& layers )
329334
prepareIndexProgress( ++i );
330335
}
331336
QgsDebugMsg( QString( "Prepare index total: %1 ms" ).arg( t.elapsed() ) );
337+
mIsIndexing = false;
332338
}
333339

334340

‎src/core/qgssnappingutils.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,9 @@ class CORE_EXPORT QgsSnappingUtils : public QObject
172172
LocatorsMap mTemporaryLocators;
173173
//! list of layer IDs that are too large to be indexed (hybrid strategy will use temporary locators for those)
174174
QSet<QString> mHybridNonindexableLayers;
175+
176+
//! internal flag that an indexing process is going on. Prevents starting two processes in parallel.
177+
bool mIsIndexing;
175178
};
176179

177180

0 commit comments

Comments
 (0)