diff options
author | João Abecasis <joao@abecasis.name> | 2009-05-06 14:12:57 (GMT) |
---|---|---|
committer | João Abecasis <joao@abecasis.name> | 2009-05-08 11:28:34 (GMT) |
commit | 42e2070925d012845db9cf85e597a17851a0dcb6 (patch) | |
tree | 5b1ab555c9b554027a3daf55e1e848e20a7ca974 /src/corelib/io | |
parent | f64bcba9338928107bb4bfc1282b94aa2f696557 (diff) | |
download | Qt-42e2070925d012845db9cf85e597a17851a0dcb6.zip Qt-42e2070925d012845db9cf85e597a17851a0dcb6.tar.gz Qt-42e2070925d012845db9cf85e597a17851a0dcb6.tar.bz2 |
Fix leak of file descriptors in QTemporaryFile
Using setFileName in QFile::copy (introduced recently) has a nasty
side-effect of leaking file descriptors in QTemporaryFile. This happens
because the code assumes the file has been closed. In QTemporaryFile,
we need to explicitly call native file engine close.
Test case by Thiago. Bug report from Arora developers.
Reviewed-by: thiago
Diffstat (limited to 'src/corelib/io')
-rw-r--r-- | src/corelib/io/qtemporaryfile.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/corelib/io/qtemporaryfile.cpp b/src/corelib/io/qtemporaryfile.cpp index 4856353..6a9125c 100644 --- a/src/corelib/io/qtemporaryfile.cpp +++ b/src/corelib/io/qtemporaryfile.cpp @@ -294,6 +294,8 @@ public: QTemporaryFileEngine(const QString &file) : QFSFileEngine(file) { } ~QTemporaryFileEngine(); + void setFileName(const QString &file); + bool open(QIODevice::OpenMode flags); bool remove(); bool close(); @@ -304,6 +306,13 @@ QTemporaryFileEngine::~QTemporaryFileEngine() QFSFileEngine::close(); } +void QTemporaryFileEngine::setFileName(const QString &file) +{ + // Really close the file, so we don't leak + QFSFileEngine::close(); + QFSFileEngine::setFileName(file); +} + bool QTemporaryFileEngine::open(QIODevice::OpenMode openMode) { Q_D(QFSFileEngine); |