@@ -398,40 +398,46 @@ void QgsFeatureListView::ensureEditSelection( bool inSelection )
398
398
399
399
if ( editSelectionUpdateRequested )
400
400
{
401
- QTimer::singleShot ( 0 , this , [ this , inSelection, validEditSelectionAvailable ]( )
401
+ if ( ! mUpdateEditSelectionTimer . isSingleShot () )
402
402
{
403
- // The layer might have been removed between timer start and timer triggered
404
- // in this case there is nothing left for us to do.
405
- if ( !layerCache () )
406
- return ;
407
-
408
- int rowToSelect = -1 ;
409
-
410
- if ( inSelection )
403
+ mUpdateEditSelectionTimer .setSingleShot ( true );
404
+ connect ( &mUpdateEditSelectionTimer , &QTimer::timeout, this , [ this , inSelection, validEditSelectionAvailable ]()
411
405
{
412
- const QgsFeatureIds selectedFids = layerCache ()->layer ()->selectedFeatureIds ();
413
- const int rowCount = mModel ->rowCount ();
406
+ // The layer might have been removed between timer start and timer triggered
407
+ // in this case there is nothing left for us to do.
408
+ if ( !layerCache () )
409
+ return ;
410
+
411
+ int rowToSelect = -1 ;
414
412
415
- for ( int i = 0 ; i < rowCount; i++ )
413
+ if ( inSelection )
416
414
{
417
- if ( selectedFids.contains ( mModel ->idxToFid ( mModel ->index ( i, 0 ) ) ) )
415
+ const QgsFeatureIds selectedFids = layerCache ()->layer ()->selectedFeatureIds ();
416
+ const int rowCount = mModel ->rowCount ();
417
+
418
+ for ( int i = 0 ; i < rowCount; i++ )
418
419
{
419
- rowToSelect = i;
420
- break ;
420
+ if ( selectedFids.contains ( mModel ->idxToFid ( mModel ->index ( i, 0 ) ) ) )
421
+ {
422
+ rowToSelect = i;
423
+ break ;
424
+ }
425
+
426
+ if ( rowToSelect == -1 && !validEditSelectionAvailable )
427
+ rowToSelect = 0 ;
421
428
}
422
-
423
- if ( rowToSelect == -1 && !validEditSelectionAvailable )
424
- rowToSelect = 0 ;
425
429
}
426
- }
427
- else
428
- rowToSelect = 0 ;
430
+ else
431
+ rowToSelect = 0 ;
429
432
430
- if ( rowToSelect != -1 )
431
- {
432
- setEditSelection ( mModel ->mapToMaster ( mModel ->index ( rowToSelect, 0 ) ), QItemSelectionModel::ClearAndSelect );
433
- }
434
- } );
433
+ if ( rowToSelect != -1 )
434
+ {
435
+ setEditSelection ( mModel ->mapToMaster ( mModel ->index ( rowToSelect, 0 ) ), QItemSelectionModel::ClearAndSelect );
436
+ }
437
+ } );
438
+ mUpdateEditSelectionTimer .setInterval ( 0 );
439
+ }
440
+ mUpdateEditSelectionTimer .start ();
435
441
}
436
442
}
437
443
0 commit comments