diff options
author | João Abecasis <joao@abecasis.name> | 2009-10-16 16:08:30 (GMT) |
---|---|---|
committer | Samuli Piippo <samuli.piippo@digia.com> | 2011-06-09 10:05:28 (GMT) |
commit | 7f093666e2e6c122750c428271b97dd39217f2b1 (patch) | |
tree | 417c41a97ae7fac2be392db759265eafe111834d /src/corelib | |
parent | d451dfaeee0d1a770c95cb11b963b496d235df8b (diff) | |
download | Qt-7f093666e2e6c122750c428271b97dd39217f2b1.zip Qt-7f093666e2e6c122750c428271b97dd39217f2b1.tar.gz Qt-7f093666e2e6c122750c428271b97dd39217f2b1.tar.bz2 |
_close(fd) closes the associated handle and not the other way around
... according to the online MSDN documentation.
Hid the cachedFd member in private data under WinCE, since it's never
used there.
Task-number: QTBUG-9085
Reviewed-by: Zeno Albisser
(cherry picked from commit 7986ab58b9a5d0828291c857d3ce86bfa1af4e6e)
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/io/qfsfileengine.cpp | 2 | ||||
-rw-r--r-- | src/corelib/io/qfsfileengine_p.h | 4 | ||||
-rw-r--r-- | src/corelib/io/qfsfileengine_win.cpp | 18 |
3 files changed, 22 insertions, 2 deletions
diff --git a/src/corelib/io/qfsfileengine.cpp b/src/corelib/io/qfsfileengine.cpp index e43d6a3..a6c20b1 100644 --- a/src/corelib/io/qfsfileengine.cpp +++ b/src/corelib/io/qfsfileengine.cpp @@ -123,8 +123,10 @@ void QFSFileEnginePrivate::init() fileAttrib = INVALID_FILE_ATTRIBUTES; fileHandle = INVALID_HANDLE_VALUE; mapHandle = INVALID_HANDLE_VALUE; +#ifndef Q_OS_WINCE cachedFd = -1; #endif +#endif } /*! diff --git a/src/corelib/io/qfsfileengine_p.h b/src/corelib/io/qfsfileengine_p.h index 131f24c..ee8bd7b 100644 --- a/src/corelib/io/qfsfileengine_p.h +++ b/src/corelib/io/qfsfileengine_p.h @@ -112,7 +112,11 @@ public: HANDLE fileHandle; HANDLE mapHandle; QHash<uchar *, DWORD /* offset % AllocationGranularity */> maps; + +#ifndef Q_OS_WINCE mutable int cachedFd; +#endif + mutable DWORD fileAttrib; #else QHash<uchar *, QPair<int /*offset % PageSize*/, size_t /*length + offset % PageSize*/> > maps; diff --git a/src/corelib/io/qfsfileengine_win.cpp b/src/corelib/io/qfsfileengine_win.cpp index 77c99e0..cc744aa 100644 --- a/src/corelib/io/qfsfileengine_win.cpp +++ b/src/corelib/io/qfsfileengine_win.cpp @@ -455,13 +455,27 @@ bool QFSFileEnginePrivate::nativeClose() // Windows native mode. bool ok = true; + +#ifndef Q_OS_WINCE + if (cachedFd != -1) { + if (::_close(cachedFd) && !::CloseHandle(fileHandle)) { + q->setError(QFile::UnspecifiedError, qt_error_string()); + ok = false; + } + + // System handle is closed with associated file descriptor. + fileHandle = INVALID_HANDLE_VALUE; + cachedFd = -1; + + return ok; + } +#endif + if ((fileHandle == INVALID_HANDLE_VALUE || !::CloseHandle(fileHandle))) { q->setError(QFile::UnspecifiedError, qt_error_string()); ok = false; } fileHandle = INVALID_HANDLE_VALUE; - cachedFd = -1; // gets closed by CloseHandle above - return ok; } |