From ad49b6860511b87360f1edc5d233c070dc8e503a Mon Sep 17 00:00:00 2001 From: hjk Date: Thu, 23 Apr 2015 09:33:52 +0200 Subject: [PATCH] TreeModel: Some extra checking Change-Id: I75751c792b22998990ef453d51b9586fdaf31f50 Reviewed-by: Eike Ziller --- src/libs/utils/treemodel.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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); }