Skip to content
Permalink
Browse files

Fix long hang when selecting huge number of vertices with node tool

  • Loading branch information
nyalldawson committed Feb 26, 2016
1 parent 0b136af commit 4f1f7a8af8c847f52523fd26c4cbfe2cfd737ee1
@@ -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 );
}
}

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

0 comments on commit 4f1f7a8

Please sign in to comment.
You can’t perform that action at this time.