forked from qt-creator/qt-creator
TreeModel: Some extra checking
Change-Id: I75751c792b22998990ef453d51b9586fdaf31f50 Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com>
This commit is contained in:
@@ -1003,8 +1003,11 @@ QModelIndex TreeModel::indexForItem(const TreeItem *item) const
|
|||||||
if (item == m_root)
|
if (item == m_root)
|
||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
|
|
||||||
|
TreeItem *p = item->parent();
|
||||||
|
QTC_ASSERT(p, return QModelIndex());
|
||||||
|
|
||||||
TreeItem *mitem = const_cast<TreeItem *>(item);
|
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);
|
return createIndex(row, 0, mitem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user