Skip to content
Permalink
Browse files
Fix crash when holding tab key in some circumstances
Fixes #44669
  • Loading branch information
nyalldawson authored and github-actions committed Aug 17, 2021
1 parent a346a56 commit 91e0745b559fe77c1bf31488e0794b4bcf35a2ef
Showing with 10 additions and 2 deletions.
  1. +10 −2 src/gui/locator/qgslocatorwidget.cpp
@@ -394,16 +394,24 @@ void QgsLocatorResultsView::recalculateSize()

void QgsLocatorResultsView::selectNextResult()
{
const int rowCount = model()->rowCount( QModelIndex() );
if ( rowCount == 0 )
return;

int nextRow = currentIndex().row() + 1;
nextRow = nextRow % model()->rowCount( QModelIndex() );
nextRow = nextRow % rowCount;
setCurrentIndex( model()->index( nextRow, 0 ) );
}

void QgsLocatorResultsView::selectPreviousResult()
{
const int rowCount = model()->rowCount( QModelIndex() );
if ( rowCount == 0 )
return;

int previousRow = currentIndex().row() - 1;
if ( previousRow < 0 )
previousRow = model()->rowCount( QModelIndex() ) - 1;
previousRow = rowCount - 1;
setCurrentIndex( model()->index( previousRow, 0 ) );
}

0 comments on commit 91e0745

Please sign in to comment.