@@ -374,30 +374,33 @@ void QgsVertexEditor::updateTableSelection()
374374 }
375375 }
376376 disconnect ( mLockedFeature , &QgsLockedFeature::selectionChanged, this , &QgsVertexEditor::updateTableSelection );
377+ disconnect ( mTableView ->selectionModel (), &QItemSelectionModel::selectionChanged, this , &QgsVertexEditor::updateVertexSelection );
377378 mTableView ->selectionModel ()->select ( selection, QItemSelectionModel::ClearAndSelect );
378379 connect ( mLockedFeature , &QgsLockedFeature::selectionChanged, this , &QgsVertexEditor::updateTableSelection );
380+ connect ( mTableView ->selectionModel (), &QItemSelectionModel::selectionChanged, this , &QgsVertexEditor::updateVertexSelection );
379381
380382 if ( firstSelectedRow >= 0 )
381383 mTableView ->scrollTo ( mVertexModel ->index ( firstSelectedRow, 0 ), QAbstractItemView::PositionAtTop );
382384
383385 mUpdatingTableSelection = false ;
384386}
385387
386- void QgsVertexEditor::updateVertexSelection ( const QItemSelection &selected , const QItemSelection & )
388+ void QgsVertexEditor::updateVertexSelection ( const QItemSelection &, const QItemSelection & )
387389{
388390 if ( !mLockedFeature || mUpdatingTableSelection )
389391 return ;
390392
391393 mUpdatingVertexSelection = true ;
394+ disconnect ( mLockedFeature , &QgsLockedFeature::selectionChanged, this , &QgsVertexEditor::updateTableSelection );
392395
393396 mLockedFeature ->deselectAllVertices ();
394397
395398 QgsCoordinateTransform t ( mLockedFeature ->layer ()->crs (), mCanvas ->mapSettings ().destinationCrs (), QgsProject::instance () );
396399 std::unique_ptr<QgsRectangle> bbox;
397- QModelIndexList indexList = selected. indexes ();
398- for ( int i = 0 ; i < indexList. length (); ++i )
400+ const QModelIndexList indexList = mTableView -> selectionModel ()-> selectedRows ();
401+ for ( const QModelIndex &index : indexList )
399402 {
400- int vertexIdx = indexList. at ( i ) .row ();
403+ int vertexIdx = index .row ();
401404 mLockedFeature ->selectVertex ( vertexIdx );
402405
403406 // create a bounding box of selected vertices
@@ -425,6 +428,7 @@ void QgsVertexEditor::updateVertexSelection( const QItemSelection &selected, con
425428 }
426429
427430 mUpdatingVertexSelection = false ;
431+ connect ( mLockedFeature , &QgsLockedFeature::selectionChanged, this , &QgsVertexEditor::updateTableSelection );
428432}
429433
430434void QgsVertexEditor::keyPressEvent ( QKeyEvent *e )
0 commit comments