Fix crash when removing layer with attribute table open

Fix #19054
This commit is contained in:
Matthias Kuhn 2018-06-04 15:55:07 +02:00
parent e5e966bb7a
commit fcb6a74d23
No known key found for this signature in database
GPG Key ID: A0E766808764D73F

View File

@ -400,6 +400,11 @@ void QgsFeatureListView::ensureEditSelection( bool inSelection )
{
QTimer::singleShot( 0, this, [ this, inSelection, validEditSelectionAvailable ]()
{
// The layer might have been removed between timer start and timer triggered
// in this case there is nothing left for us to do.
if ( !layerCache() )
return;
int rowToSelect = -1;
if ( inSelection )
@ -423,7 +428,9 @@ void QgsFeatureListView::ensureEditSelection( bool inSelection )
rowToSelect = 0;
if ( rowToSelect != -1 )
{
setEditSelection( mModel->mapToMaster( mModel->index( rowToSelect, 0 ) ), QItemSelectionModel::ClearAndSelect );
}
} );
}
}