summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJoão Abecasis <joao@abecasis.name>2009-05-18 09:51:12 (GMT)
committerJoão Abecasis <joao@abecasis.name>2009-05-22 12:33:48 (GMT)
commita0396c8c68aca446e68434e516bd46d749093b0f (patch)
tree6deb97426949d3e3fa1a368cb06abbf4f72584f9 /src
parentba706d2564f1181fa4cc596a46bb2a041c62c28f (diff)
downloadQt-a0396c8c68aca446e68434e516bd46d749093b0f.zip
Qt-a0396c8c68aca446e68434e516bd46d749093b0f.tar.gz
Qt-a0396c8c68aca446e68434e516bd46d749093b0f.tar.bz2
Reset openMode to NotOpen when returning false from QFile::open()
When connecting to an open file descriptor, set the openMode in the file system engine, as is done for file handles. Reviewed-by: Thiago
Diffstat (limited to 'src')
-rw-r--r--src/corelib/io/qfsfileengine.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/corelib/io/qfsfileengine.cpp b/src/corelib/io/qfsfileengine.cpp
index 61ea7cc..1c8f0e9 100644
--- a/src/corelib/io/qfsfileengine.cpp
+++ b/src/corelib/io/qfsfileengine.cpp
@@ -312,6 +312,10 @@ bool QFSFileEnginePrivate::openFh(QIODevice::OpenMode openMode, FILE *fh)
if (ret == -1) {
q->setError(errno == EMFILE ? QFile::ResourceError : QFile::OpenError,
qt_error_string(int(errno)));
+
+ this->openMode = QIODevice::NotOpen;
+ this->fh = 0;
+
return false;
}
}
@@ -335,6 +339,7 @@ bool QFSFileEngine::open(QIODevice::OpenMode openMode, int fd)
if ((openMode & QFile::WriteOnly) && !(openMode & (QFile::ReadOnly | QFile::Append)))
openMode |= QFile::Truncate;
+ d->openMode = openMode;
d->lastFlushFailed = false;
d->closeFileHandle = false;
d->nativeFilePath.clear();
@@ -367,6 +372,10 @@ bool QFSFileEnginePrivate::openFd(QIODevice::OpenMode openMode, int fd)
if (ret == -1) {
q->setError(errno == EMFILE ? QFile::ResourceError : QFile::OpenError,
qt_error_string(int(errno)));
+
+ this->openMode = QIODevice::NotOpen;
+ this->fd = -1;
+
return false;
}
}