Fix last > rowCount() assert in ClassModel Node dtor
Summary:
This patch fixes another assert in the classmodel.
This time it is the assert triggered from
Node::~Node -> ClassModel::nodesAboutToBeRemoved -> QAbstractItemModel::beginRemoveRows(index, first, last)
last > rowCount(), last was greater than the rowCount.
This is because in Node::removeNode the child was first removed from the childrenlist and then deleted.
But createIndex() & rowCount() rely on the item to still be in the model/list. Node::row() would simply return -1 which would result in an invalid index.
rowCount for invalid index < last Item
The solution is simple, like in Node::clear(), first delete the item and then remove it from the list.
Test Plan:
- compile Qt 5.11.1 with debug&asserts enabled
- compile kdevelop against this version of Qt
- start kdevelop and open a project
- open the Classes toolview
- expand & collapse some items
-> assert/crash
Reviewers: KDevelop, brauch
Reviewed By: KDevelop, brauch
Subscribers: brauch, kdevelop-devel
Tags: KDevelop
Differential Revision: https://phabricator.kde.org/D14840