Commit c1b20ade authored by Eike Ziller's avatar Eike Ziller

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
......@@ -157,10 +157,14 @@ IFindSupport::Result TreeViewFind::find(const QString &searchTxt,
*wrapped = false;
if (searchTxt.isEmpty())
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);
QModelIndex resultIndex;
QModelIndex currentIndex = d->m_view->currentIndex();
QModelIndex index = currentIndex;
int currentRow = currentIndex.row();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment