From e6f148e576a3b62c671b02722b77956d4070acde Mon Sep 17 00:00:00 2001 From: Martin Dobias Date: Thu, 7 Feb 2019 18:04:05 +0100 Subject: [PATCH] [vertex tool] do not clear selection of vertices after a move The list of selected vertices was getting prematurely cleared. Also had to remove a piece of code to select some vertices of the locked feature (was causing a crash) but the logic seemed wrong anyway (and there is a planned work on sync between vertex editor and tool) --- src/app/vertextool/qgsvertextool.cpp | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/app/vertextool/qgsvertextool.cpp b/src/app/vertextool/qgsvertextool.cpp index 37a3c964e06..cbe73284d20 100644 --- a/src/app/vertextool/qgsvertextool.cpp +++ b/src/app/vertextool/qgsvertextool.cpp @@ -2030,18 +2030,10 @@ void QgsVertexTool::applyEditsToLayers( QgsVertexTool::VertexEdits &edits ) for ( ; it2 != layerEdits.end(); ++it2 ) { layer->changeGeometry( it2.key(), it2.value() ); - for ( int i = 0; i < mSelectedVertices.length(); ++i ) - { - if ( mSelectedVertices.at( i ).layer == layer && mSelectedVertices.at( i ).fid == it2.key() ) - { - mSelectedFeature->selectVertex( mSelectedVertices.at( i ).vertexId ); - } - } } layer->endEditCommand(); layer->triggerRepaint(); - if ( mVertexEditor ) mVertexEditor->updateEditor( mSelectedFeature.get() ); } @@ -2209,6 +2201,11 @@ void QgsVertexTool::deleteVertex() void QgsVertexTool::setHighlightedVertices( const QList &listVertices, HighlightMode mode ) { + // we need to make a local copy of vertices - often this method gets called + // just to refresh positions and so mSelectedVertices is passed. But then in reset mode + // we clear that array, which could clear also listVertices. + QList listVerticesLocal( listVertices ); + if ( mode == ModeReset ) { qDeleteAll( mSelectedVerticesMarkers ); @@ -2241,7 +2238,7 @@ void QgsVertexTool::setHighlightedVertices( const QList &listVertices, H return true; }; - for ( const Vertex &vertex : listVertices ) + for ( const Vertex &vertex : listVerticesLocal ) { if ( mode == ModeAdd && mSelectedVertices.contains( vertex ) ) {