D14840: Fix last > rowCount() assert in ClassModel Node dtor
Bernd Buschinski
noreply at phabricator.kde.org
Tue Aug 14 16:21:43 BST 2018
buschinski created this revision.
buschinski added a reviewer: KDevelop.
Herald added a project: KDevelop.
Herald added a subscriber: kdevelop-devel.
buschinski requested review of this revision.
REVISION 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
REPOSITORY
R32 KDevelop
REVISION DETAIL
https://phabricator.kde.org/D14840
AFFECTED FILES
kdevplatform/language/classmodel/classmodelnode.cpp
To: buschinski, #kdevelop
Cc: kdevelop-devel, antismap, iodelay, vbspam, geetamc, Pilzschaf, akshaydeo, surgenight, arrowd
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kdevelop-devel/attachments/20180814/8bf388c5/attachment.html>
More information about the KDevelop-devel
mailing list