Fix concurrency issue in snap indexing

This commit is contained in:
Matthias Kuhn 2015-09-24 08:16:26 +02:00
parent 8a949fa1a6
commit 287590eea2
3 changed files with 11 additions and 2 deletions

View File

@ -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)

View File

@ -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;
}

View File

@ -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;
};