AutoTest: Fix crash on close

Introduced with latest changes to TreeItem.
It is a bad idea to remove child items while iterating over them.

Change-Id: I6941f4728cf93e47b3ef6405bd1304112946c481
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Christian Stenger
2017-02-09 09:29:12 +01:00
parent fd8ee7f044
commit f00a113eb4

View File

@@ -67,7 +67,10 @@ TestTreeModel *TestTreeModel::instance()
TestTreeModel::~TestTreeModel()
{
for (Utils::TreeItem *item : *rootItem()) {
const Utils::TreeItem *invisibleRoot = rootItem();
const int frameworkRootCount = invisibleRoot ? invisibleRoot->childCount() : 0;
for (int row = frameworkRootCount - 1; row >= 0; --row) {
Utils::TreeItem *item = invisibleRoot->childAt(row);
item->removeChildren();
takeItem(item); // do NOT delete the item as it's still a ptr hold by TestFrameworkManager
}