QFileSystemModel: add an assert to prevent leaks

Private::addNode() adds the new node to the parent's hash without
checking whether a node already exists. If it does, then the old
node is leaked.

Add an assertion to check for this condition.

Change-Id: Ib949d71c86c28d1152a538756c0efc283c793c24
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
bb10
Marc Mutz 2016-09-30 11:54:54 +02:00
parent b5662ba603
commit 8a25006fad
1 changed files with 1 additions and 0 deletions

View File

@ -1698,6 +1698,7 @@ QFileSystemModelPrivate::QFileSystemNode* QFileSystemModelPrivate::addNode(QFile
node->volumeName = QString::fromWCharArray(name);
}
#endif
Q_ASSERT(!parentNode->children.contains(fileName));
parentNode->children.insert(fileName, node);
return node;
}