Skip to content
Snippets Groups Projects
Commit c1b20ade authored by Eike Ziller's avatar Eike Ziller
Browse files

TreeViewFind: Fix endless loop if tree view has nothing selected


If the tree view has nothing selected, the search would wrap endlessly
because the current index is invalid, but wrapping restarted at the
first toplevel index.

Change-Id: I31badb2038c8752d2c91e6fcaff69138c846383e
Reviewed-by: default avatarDaniel Teske <daniel.teske@digia.com>
parent 0f518a7d
No related branches found
No related tags found
No related merge requests found
...@@ -157,10 +157,14 @@ IFindSupport::Result TreeViewFind::find(const QString &searchTxt, ...@@ -157,10 +157,14 @@ IFindSupport::Result TreeViewFind::find(const QString &searchTxt,
*wrapped = false; *wrapped = false;
if (searchTxt.isEmpty()) if (searchTxt.isEmpty())
return IFindSupport::NotFound; return IFindSupport::NotFound;
if (d->m_view->model()->rowCount() <= 0) // empty model
return IFindSupport::NotFound;
QModelIndex currentIndex = d->m_view->currentIndex();
if (!currentIndex.isValid()) // nothing selected, start from top
currentIndex = d->m_view->model()->index(0, 0);
QTextDocument::FindFlags flags = textDocumentFlagsForFindFlags(findFlags); QTextDocument::FindFlags flags = textDocumentFlagsForFindFlags(findFlags);
QModelIndex resultIndex; QModelIndex resultIndex;
QModelIndex currentIndex = d->m_view->currentIndex();
QModelIndex index = currentIndex; QModelIndex index = currentIndex;
int currentRow = currentIndex.row(); int currentRow = currentIndex.row();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment