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>bb10
parent
54b0e94cfb
commit
5c87044870
|
|
@ -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();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -120,6 +120,20 @@ public:
|
|||
metaData = QFileSystemMetaData();
|
||||
}
|
||||
|
||||
inline QFileInfoPrivate(const QFileSystemEntry &file, const QFileSystemMetaData &data, QAbstractFileEngine *engine)
|
||||
: fileEntry(file),
|
||||
metaData(data),
|
||||
fileEngine(engine),
|
||||
cachedFlags(0),
|
||||
#ifndef QT_NO_FSFILEENGINE
|
||||
isDefaultConstructed(false),
|
||||
#else
|
||||
isDefaultConstructed(!fileEngine),
|
||||
#endif
|
||||
cache_enabled(true), fileFlags(0), fileSize(0)
|
||||
{
|
||||
}
|
||||
|
||||
inline void clearFlags() const {
|
||||
fileFlags = 0;
|
||||
cachedFlags = 0;
|
||||
|
|
|
|||
Loading…
Reference in New Issue