Skip to content
Permalink
Browse files
Merge pull request #44719 from qgis/backport-44718-to-release-3_16
[Backport release-3_16] Fix crash when holding tab key in some circumstances
  • Loading branch information
rouault committed Aug 17, 2021
2 parents e5b665e + 615069e commit be8d76e2482d8207ed94b0977216ba1232eb2450
Showing with 10 additions and 2 deletions.
  1. +10 −2 src/gui/locator/qgslocatorwidget.cpp
@@ -388,16 +388,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 be8d76e

Please sign in to comment.