Skip to content

Commit

Permalink
Fix long hang when selecting huge number of vertices with node tool
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Feb 26, 2016
1 parent 0b136af commit 4f1f7a8
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
8 changes: 5 additions & 3 deletions src/app/nodetool/qgsmaptoolnodetool.cpp
Expand Up @@ -516,14 +516,16 @@ void QgsMapToolNodeTool::canvasReleaseEvent( QgsMapMouseEvent* e )
mSelectedFeature->deselectAllVertexes();
}

QVector< int > toSelect;
for ( int i = 0; i < vertexMap.size(); i++ )
{
if ( r.contains( vertexMap[i]->pointV1() ) )
if ( r.contains( vertexMap.at( i )->pointV1() ) )
{
// inverting selection is enough because all were deselected if ctrl is not pressed
mSelectedFeature->invertVertexSelection( i );
toSelect << i;
}
}
// inverting selection is enough because all were deselected if ctrl is not pressed
mSelectedFeature->invertVertexSelection( toSelect );
}
}

Expand Down
13 changes: 13 additions & 0 deletions src/app/nodetool/qgsselectedfeature.cpp
Expand Up @@ -482,6 +482,19 @@ void QgsSelectedFeature::invertVertexSelection( int vertexNr )
emit selectionChanged();
}

void QgsSelectedFeature::invertVertexSelection( QVector<int> vertexIndices )
{
Q_FOREACH ( int index, vertexIndices )
{
if ( index < 0 || index >= mVertexMap.size() )
continue;

QgsVertexEntry *entry = mVertexMap.at( index );
entry->setSelected( !entry->isSelected() );
}
emit selectionChanged();
}

void QgsSelectedFeature::updateVertexMarkersPosition()
{
Q_FOREACH ( QgsVertexEntry* vertexEntry, mVertexMap )
Expand Down
7 changes: 6 additions & 1 deletion src/app/nodetool/qgsselectedfeature.h
Expand Up @@ -85,10 +85,15 @@ class QgsSelectedFeature: public QObject
/**
* Inverts selection of vertex with number
* @param vertexNr number of vertex which is to be inverted
* @param invert flag if vertex selection should be inverted or not
*/
void invertVertexSelection( int vertexNr );

/**
* Inverts selection of a set of vertices at once.
* @param vertexIndices list of vertex indices to invert whether or not they are selected
*/
void invertVertexSelection(QVector<int> vertexIndices );

/**
* Tells if vertex is selected
* @param vertexNr number of vertex for which we are getting info
Expand Down

0 comments on commit 4f1f7a8

Please sign in to comment.