Skip to content

Commit 615069e

Browse files
nyalldawsongithub-actions[bot]
authored andcommittedAug 17, 2021
Fix crash when holding tab key in some circumstances
Fixes #44669
1 parent e5b665e commit 615069e

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
@@ -388,16 +388,24 @@ void QgsLocatorResultsView::recalculateSize()
388388

389389
void QgsLocatorResultsView::selectNextResult()
390390
{
391+
const int rowCount = model()->rowCount( QModelIndex() );
392+
if ( rowCount == 0 )
393+
return;
394+
391395
int nextRow = currentIndex().row() + 1;
392-
nextRow = nextRow % model()->rowCount( QModelIndex() );
396+
nextRow = nextRow % rowCount;
393397
setCurrentIndex( model()->index( nextRow, 0 ) );
394398
}
395399

396400
void QgsLocatorResultsView::selectPreviousResult()
397401
{
402+
const int rowCount = model()->rowCount( QModelIndex() );
403+
if ( rowCount == 0 )
404+
return;
405+
398406
int previousRow = currentIndex().row() - 1;
399407
if ( previousRow < 0 )
400-
previousRow = model()->rowCount( QModelIndex() ) - 1;
408+
previousRow = rowCount - 1;
401409
setCurrentIndex( model()->index( previousRow, 0 ) );
402410
}
403411

0 commit comments

Comments
 (0)
Please sign in to comment.