diff --git a/src/libs/utils/treemodel.cpp b/src/libs/utils/treemodel.cpp index fa16a80e3fc..11076d13582 100644 --- a/src/libs/utils/treemodel.cpp +++ b/src/libs/utils/treemodel.cpp @@ -1003,8 +1003,11 @@ QModelIndex TreeModel::indexForItem(const TreeItem *item) const if (item == m_root) return QModelIndex(); + TreeItem *p = item->parent(); + QTC_ASSERT(p, return QModelIndex()); + TreeItem *mitem = const_cast(item); - int row = item->parent()->m_children.indexOf(mitem); + int row = p->m_children.indexOf(mitem); return createIndex(row, 0, mitem); }