summaryrefslogtreecommitdiffstats
path: root/src/widgets
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2016-09-30 11:23:21 +0200
committerMarc Mutz <marc.mutz@kdab.com>2016-10-04 17:12:26 +0000
commitbf595c4e78187e78d7bedc3e9f95fe5b38683fed (patch)
treec7291a10624d4d687af07e809e4757d3eb7ac636 /src/widgets
parentd6b6c15d338320a8f9fb3299121c3b338f2b6481 (diff)
QFileSystemModel: Plug leak on file renaming
In setData(), the old code both called Private::addNode(), which creates a QFileSystemNode and adds it to the parent's QHash of children, and also re-purposed the old node by taking it out of the children hash, adjusting the fileName member of the node and putting it back into the children hash under the new name, where it would overwrite the node just added under the same (new) name in addNode(). Since the hash stores naked pointers, no-one deletes the node that was put into the hash first. Fix by dropping the addNode() call completely. Change-Id: I0c37917fd0ffd74716393786c69b5bb172aa372e Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/dialogs/qfilesystemmodel.cpp1
1 files changed, 0 insertions, 1 deletions
diff --git a/src/widgets/dialogs/qfilesystemmodel.cpp b/src/widgets/dialogs/qfilesystemmodel.cpp
index a4d4230044..8e4697077e 100644
--- a/src/widgets/dialogs/qfilesystemmodel.cpp
+++ b/src/widgets/dialogs/qfilesystemmodel.cpp
@@ -885,7 +885,6 @@ bool QFileSystemModel::setData(const QModelIndex &idx, const QVariant &value, in
QFileSystemModelPrivate::QFileSystemNode *parentNode = indexNode->parent;
int visibleLocation = parentNode->visibleLocation(parentNode->children.value(indexNode->fileName)->fileName);
- d->addNode(parentNode, newName,indexNode->info->fileInfo());
parentNode->visibleChildren.removeAt(visibleLocation);
QFileSystemModelPrivate::QFileSystemNode * oldValue = parentNode->children.value(oldName);
parentNode->children[newName] = oldValue;