Skip to content

Commit a82a773

Browse files
signedavgithub-actions[bot]
authored andcommittedMar 7, 2023
Check selection.indexes if empty before getting first() to avoid danger of nullptr.
1 parent 9798f8e commit a82a773

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed
 

‎src/gui/attributetable/qgsfeaturelistview.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,9 +185,13 @@ void QgsFeatureListView::editSelectionChanged( const QItemSelection &selected, c
185185

186186
if ( !selected.isEmpty() )
187187
{
188-
QgsFeature selectedFeature;
189-
mModel->featureByIndex( mModel->mapFromMaster( selected.indexes().first() ), selectedFeature );
190-
mLastEditSelectionFid = selectedFeature.id();
188+
const QModelIndexList indexList = selected.indexes();
189+
if ( !indexList.isEmpty() )
190+
{
191+
QgsFeature selectedFeature;
192+
mModel->featureByIndex( mModel->mapFromMaster( indexList.first() ), selectedFeature );
193+
mLastEditSelectionFid = selectedFeature.id();
194+
}
191195
}
192196

193197
const QItemSelection currentSelection = mCurrentEditSelectionModel->selection();

0 commit comments

Comments
 (0)
Please sign in to comment.