Skip to content

Commit 4f1f7a8

Browse files
committed
Fix long hang when selecting huge number of vertices with node tool
1 parent 0b136af commit 4f1f7a8

File tree

3 files changed

+24
-4
lines changed

3 files changed

+24
-4
lines changed

src/app/nodetool/qgsmaptoolnodetool.cpp

+5-3
Original file line numberDiff line numberDiff line change
@@ -516,14 +516,16 @@ void QgsMapToolNodeTool::canvasReleaseEvent( QgsMapMouseEvent* e )
516516
mSelectedFeature->deselectAllVertexes();
517517
}
518518

519+
QVector< int > toSelect;
519520
for ( int i = 0; i < vertexMap.size(); i++ )
520521
{
521-
if ( r.contains( vertexMap[i]->pointV1() ) )
522+
if ( r.contains( vertexMap.at( i )->pointV1() ) )
522523
{
523-
// inverting selection is enough because all were deselected if ctrl is not pressed
524-
mSelectedFeature->invertVertexSelection( i );
524+
toSelect << i;
525525
}
526526
}
527+
// inverting selection is enough because all were deselected if ctrl is not pressed
528+
mSelectedFeature->invertVertexSelection( toSelect );
527529
}
528530
}
529531

src/app/nodetool/qgsselectedfeature.cpp

+13
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,19 @@ void QgsSelectedFeature::invertVertexSelection( int vertexNr )
482482
emit selectionChanged();
483483
}
484484

485+
void QgsSelectedFeature::invertVertexSelection( QVector<int> vertexIndices )
486+
{
487+
Q_FOREACH ( int index, vertexIndices )
488+
{
489+
if ( index < 0 || index >= mVertexMap.size() )
490+
continue;
491+
492+
QgsVertexEntry *entry = mVertexMap.at( index );
493+
entry->setSelected( !entry->isSelected() );
494+
}
495+
emit selectionChanged();
496+
}
497+
485498
void QgsSelectedFeature::updateVertexMarkersPosition()
486499
{
487500
Q_FOREACH ( QgsVertexEntry* vertexEntry, mVertexMap )

src/app/nodetool/qgsselectedfeature.h

+6-1
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,15 @@ class QgsSelectedFeature: public QObject
8585
/**
8686
* Inverts selection of vertex with number
8787
* @param vertexNr number of vertex which is to be inverted
88-
* @param invert flag if vertex selection should be inverted or not
8988
*/
9089
void invertVertexSelection( int vertexNr );
9190

91+
/**
92+
* Inverts selection of a set of vertices at once.
93+
* @param vertexIndices list of vertex indices to invert whether or not they are selected
94+
*/
95+
void invertVertexSelection(QVector<int> vertexIndices );
96+
9297
/**
9398
* Tells if vertex is selected
9499
* @param vertexNr number of vertex for which we are getting info

0 commit comments

Comments
 (0)