summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qfileinfo.cpp
diff options
context:
space:
mode:
authorJian Liang <jianliang79@gmail.com>2013-10-10 14:28:22 +0800
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-10-12 10:52:03 +0200
commit5c87044870752ba9506d7f1d6a0b3de13e72c45f (patch)
tree97005a8aa015995309f361ae7541ec22d2ff8049 /src/corelib/io/qfileinfo.cpp
parent54b0e94cfb04aab67205c49203427c914269f0ad (diff)
Fix memory leak in QFileInfo::exists()
Use the the legacy file engine object created in static function QFileInfo::exists() as the engine of the QFileInfo object to prevent memory leak. This can also boost a little performance. Change-Id: I06317d158d487be5ef15fe3244a917a371563ac9 Reviewed-by: hjk <hjk121@nokiamail.com> Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
Diffstat (limited to 'src/corelib/io/qfileinfo.cpp')
-rw-r--r--src/corelib/io/qfileinfo.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/corelib/io/qfileinfo.cpp b/src/corelib/io/qfileinfo.cpp
index 90122a9f0d..1c216f8a6b 100644
--- a/src/corelib/io/qfileinfo.cpp
+++ b/src/corelib/io/qfileinfo.cpp
@@ -691,7 +691,8 @@ bool QFileInfo::exists(const QString &file)
QFileSystemEngine::resolveEntryAndCreateLegacyEngine(entry, data);
// Expensive fallback to non-QFileSystemEngine implementation
if (engine)
- return QFileInfo(file).exists();
+ return QFileInfo(new QFileInfoPrivate(entry, data, engine)).exists();
+
QFileSystemEngine::fillMetaData(entry, data, QFileSystemMetaData::ExistsAttribute);
return data.exists();
}