Skip to content

Commit 8e7e751

Browse files
committedAug 17, 2021
Fix crash when holding tab key in some circumstances
Fixes #44669
1 parent 06b3b16 commit 8e7e751

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed
 

‎src/gui/locator/qgslocatorwidget.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -401,16 +401,24 @@ void QgsLocatorResultsView::recalculateSize()
401401

402402
void QgsLocatorResultsView::selectNextResult()
403403
{
404+
const int rowCount = model()->rowCount( QModelIndex() );
405+
if ( rowCount == 0 )
406+
return;
407+
404408
int nextRow = currentIndex().row() + 1;
405-
nextRow = nextRow % model()->rowCount( QModelIndex() );
409+
nextRow = nextRow % rowCount;
406410
setCurrentIndex( model()->index( nextRow, 0 ) );
407411
}
408412

409413
void QgsLocatorResultsView::selectPreviousResult()
410414
{
415+
const int rowCount = model()->rowCount( QModelIndex() );
416+
if ( rowCount == 0 )
417+
return;
418+
411419
int previousRow = currentIndex().row() - 1;
412420
if ( previousRow < 0 )
413-
previousRow = model()->rowCount( QModelIndex() ) - 1;
421+
previousRow = rowCount - 1;
414422
setCurrentIndex( model()->index( previousRow, 0 ) );
415423
}
416424

0 commit comments

Comments
 (0)
Please sign in to comment.