Skip to content

Commit

Permalink
Fix UI hang when selecting vertices from complex features when releasing
Browse files Browse the repository at this point in the history
the mouse button after a drag operation

For large geometries the total vertex count was being calculated
once per vertex, resulting in a lot of unnecessary extra work
  • Loading branch information
nyalldawson committed Mar 17, 2021
1 parent 64d04ed commit 6909b45
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/app/vertextool/qgsvertextool.cpp
Expand Up @@ -601,9 +601,10 @@ void QgsVertexTool::cadCanvasReleaseEvent( QgsMapMouseEvent *e )

bool isFeatureSelected = vlayer->selectedFeatureIds().contains( f.id() );
QgsGeometry g = f.geometry();
for ( int i = 0; i < g.constGet()->nCoordinates(); ++i )
int i = 0;
for ( auto it = g.constGet()->vertices_begin(); it != g.constGet()->vertices_end(); ++it )
{
QgsPoint pt = g.vertexAt( i );
QgsPoint pt = *it;
if ( layerRubberBandEngine->contains( &pt ) )
{
// we don't want to select invisible features,
Expand All @@ -618,6 +619,7 @@ void QgsVertexTool::cadCanvasReleaseEvent( QgsMapMouseEvent *e )
if ( isFeatureSelected )
selectedVertices << Vertex( vlayer, f.id(), i );
}
i++;
}
}
if ( r )
Expand Down

0 comments on commit 6909b45

Please sign in to comment.