summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/corelib/io/qfsfileengine_win.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/corelib/io/qfsfileengine_win.cpp b/src/corelib/io/qfsfileengine_win.cpp
index 2d4fe0e..2fc9670 100644
--- a/src/corelib/io/qfsfileengine_win.cpp
+++ b/src/corelib/io/qfsfileengine_win.cpp
@@ -1927,8 +1927,9 @@ uchar *QFSFileEnginePrivate::map(qint64 offset, qint64 size,
#ifndef Q_OS_WINCE
if (handle == INVALID_HANDLE_VALUE && fh)
handle = (HANDLE)_get_osfhandle(QT_FILENO(fh));
-#else
- #ifdef Q_USE_DEPRECATED_MAP_API
+#endif
+
+#ifdef Q_USE_DEPRECATED_MAP_API
if (fileMapHandle == INVALID_HANDLE_VALUE) {
nativeClose();
fileMapHandle = CreateFileForMapping((const wchar_t*)nativeFilePath.constData(),
@@ -1940,11 +1941,13 @@ uchar *QFSFileEnginePrivate::map(qint64 offset, qint64 size,
NULL);
}
handle = fileMapHandle;
- #endif
- if (handle == INVALID_HANDLE_VALUE && fh)
- return 0;
#endif
+ if (handle == INVALID_HANDLE_VALUE) {
+ q->setError(QFile::UnspecifiedError, QLatin1String("No handle on file"));
+ return 0;
+ }
+
// first create the file mapping handle
DWORD protection = (openMode & QIODevice::WriteOnly) ? PAGE_READWRITE : PAGE_READONLY;
HANDLE mapHandle = ::CreateFileMapping(handle, 0, protection, 0, 0, 0);