TreeModel: Some extra checking

Change-Id: I75751c792b22998990ef453d51b9586fdaf31f50
Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com>
This commit is contained in:
hjk
2015-04-23 09:33:52 +02:00
parent f02e09f60e
commit ad49b68605

View File

@@ -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<TreeItem *>(item);
int row = item->parent()->m_children.indexOf(mitem);
int row = p->m_children.indexOf(mitem);
return createIndex(row, 0, mitem);
}