QNetworkDiskCache - fix leak of file descriptor

When the caches is deleted, the open files are deleted without closing action.
The file descriptor is remaining until the process is terminated.

Change-Id: If85519d173d05548ddf3273c85800441887199e2
Reviewed-by: jungo kim <jungo.kim@lge.com>
Reviewed-by: Peter Hartmann <phartmann@blackberry.com>
This commit is contained in:
Jungo Kim 2014-01-10 11:51:33 +09:00 committed by The Qt Project
parent c58c98a248
commit 69bf59ecfd

View File

@ -559,6 +559,20 @@ qint64 QNetworkDiskCache::expire()
break;
QString name = i.value();
QFile file(name);
if (name.contains(PREPARED_SLASH)) {
QHashIterator<QIODevice*, QCacheItem*> iterator(d->inserting);
while (iterator.hasNext()) {
iterator.next();
QCacheItem *item = iterator.value();
if (item && item->file && item->file->fileName() == name) {
delete item->file;
item->file = 0;
break;
}
}
}
qint64 size = file.size();
file.remove();
totalSize -= size;