<table><tr><td style="">buschinski created this revision.<br />buschinski added a reviewer: KDevelop.<br />Herald added a project: KDevelop.<br />Herald added a subscriber: kdevelop-devel.<br />buschinski requested review of this revision.
</td><a style="text-decoration: none; padding: 4px 8px; margin: 0 8px 8px; float: right; color: #464C5C; font-weight: bold; border-radius: 3px; background-color: #F7F7F9; background-image: linear-gradient(to bottom,#fff,#f1f0f1); display: inline-block; border: 1px solid rgba(71,87,120,.2);" href="https://phabricator.kde.org/D14840">View Revision</a></tr></table><br /><div><strong>REVISION SUMMARY</strong><div><p>This patch fixes another assert in the classmodel.<br />
This time it is the assert triggered from<br />
Node::~Node -> ClassModel::nodesAboutToBeRemoved -> QAbstractItemModel::beginRemoveRows(index, first, last)</p>

<p>last > rowCount(), last was greater than the rowCount.</p>

<p>This is because in Node::removeNode the child was first removed from the childrenlist and then deleted.<br />
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.</p>

<p>rowCount for invalid index < last Item</p>

<p>The solution is simple, like in Node::clear(), first delete the item and then remove it from the list.</p></div></div><br /><div><strong>TEST PLAN</strong><div><ul class="remarkup-list">
<li class="remarkup-list-item">compile Qt 5.11.1 with debug&asserts enabled</li>
<li class="remarkup-list-item">compile kdevelop against this version of Qt</li>
<li class="remarkup-list-item">start kdevelop and open a project</li>
<li class="remarkup-list-item">open the Classes toolview</li>
<li class="remarkup-list-item">expand & collapse some items</li>
</ul>

<p>-> assert/crash</p></div></div><br /><div><strong>REPOSITORY</strong><div><div>R32 KDevelop</div></div></div><br /><div><strong>REVISION DETAIL</strong><div><a href="https://phabricator.kde.org/D14840">https://phabricator.kde.org/D14840</a></div></div><br /><div><strong>AFFECTED FILES</strong><div><div>kdevplatform/language/classmodel/classmodelnode.cpp</div></div></div><br /><div><strong>To: </strong>buschinski, KDevelop<br /><strong>Cc: </strong>kdevelop-devel, antismap, iodelay, vbspam, geetamc, Pilzschaf, akshaydeo, surgenight, arrowd<br /></div>