Skip to content

Commit

Permalink
Merge pull request #44720 from qgis/backport-44718-to-release-3_20
Browse files Browse the repository at this point in the history
[Backport release-3_20] Fix crash when holding tab key in some circumstances
  • Loading branch information
rouault committed Aug 17, 2021
2 parents a346a56 + 91e0745 commit 95481a9
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/gui/locator/qgslocatorwidget.cpp
Expand Up @@ -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 ) );
}

Expand Down

0 comments on commit 95481a9

Please sign in to comment.