Skip to content
Permalink
Browse files

Fix concurrency issue in snap indexing

  • Loading branch information
m-kuhn committed Sep 24, 2015
1 parent 8a949fa commit 287590eea2249f9008644355c4c1f3b3fe974c20
Showing with 11 additions and 2 deletions.
  1. +2 −2 qgis-test-travis.ctest
  2. +6 −0 src/core/qgssnappingutils.cpp
  3. +3 −0 src/core/qgssnappingutils.h
@@ -69,14 +69,14 @@ ENDIF(NOT ${BUILDRES} EQUAL 0 OR NOT ${NUMERR} EQUAL 0)
IF(NOT ${NUMWARN} EQUAL 0)
ctest_submit (RETRY_COUNT 3 RETRY_DELAY 30)
MESSAGE("${Yellow}Test results submitted to${ColorReset}")
MESSAGE("${BoldYellow}${SHORTURL}{ColorReset}" )
MESSAGE("${BoldYellow}${SHORTURL}${ColorReset}" )
MESSAGE( FATAL_ERROR "${Red}Build warnings found, aborting test.${ColorReset}" )
ENDIF(NOT ${NUMWARN} EQUAL 0)
ctest_test (BUILD "${CTEST_BINARY_DIRECTORY}" PARALLEL_LEVEL 2 RETURN_VALUE TESTRES)
IF(NOT ${TESTRES} EQUAL 0)
ctest_submit (RETRY_COUNT 3 RETRY_DELAY 30)
MESSAGE("${Yellow}Test results submitted to${ColorReset}")
MESSAGE("${BoldYellow}${SHORTURL}{ColorReset}" )
MESSAGE("${BoldYellow}${SHORTURL}${ColorReset}" )
MESSAGE( FATAL_ERROR "Tests failed" )
ENDIF(NOT ${TESTRES} EQUAL 0)

@@ -30,6 +30,7 @@ QgsSnappingUtils::QgsSnappingUtils( QObject* parent )
, mDefaultTolerance( 10 )
, mDefaultUnit( QgsTolerance::Pixels )
, mSnapOnIntersection( false )
, mIsIndexing( false )
{
connect( QgsMapLayerRegistry::instance(), SIGNAL( layersWillBeRemoved( QStringList ) ), this, SLOT( onLayersWillBeRemoved( QStringList ) ) );
}
@@ -306,6 +307,10 @@ QgsPointLocator::Match QgsSnappingUtils::snapToMap( const QgsPoint& pointMap, Qg

void QgsSnappingUtils::prepareIndex( const QList<QgsVectorLayer*>& layers )
{
if ( mIsIndexing )
return;
mIsIndexing = true;

// check if we need to build any index
QList<QgsVectorLayer*> layersToIndex;
Q_FOREACH ( QgsVectorLayer* vl, layers )
@@ -329,6 +334,7 @@ void QgsSnappingUtils::prepareIndex( const QList<QgsVectorLayer*>& layers )
prepareIndexProgress( ++i );
}
QgsDebugMsg( QString( "Prepare index total: %1 ms" ).arg( t.elapsed() ) );
mIsIndexing = false;
}


@@ -172,6 +172,9 @@ class CORE_EXPORT QgsSnappingUtils : public QObject
LocatorsMap mTemporaryLocators;
//! list of layer IDs that are too large to be indexed (hybrid strategy will use temporary locators for those)
QSet<QString> mHybridNonindexableLayers;

//! internal flag that an indexing process is going on. Prevents starting two processes in parallel.
bool mIsIndexing;
};


0 comments on commit 287590e

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