diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2017-07-05 14:41:11 -0700 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2017-07-07 21:39:16 +0000 |
commit | 8d542154a82e4a7b14cffbe46ae493085b9eb4f6 (patch) | |
tree | a0fc0de3a829bae680367d4e0cf2cb99ccacfa36 | |
parent | fd95ef765afa3b0fd9996a31546d098465b927fe (diff) |
Avoid sharing violation in QFileSystemEngine::id on Windows
We can't open a file for reading if the file is open by another process
(or by ourselves) without sharing permitted. So ask for no access just
so we can get a handle to it.
Change-Id: I998653739e1cec2a58a07a6593b6ff87c1d59dd1
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
-rw-r--r-- | src/corelib/io/qfilesystemengine_win.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/corelib/io/qfilesystemengine_win.cpp b/src/corelib/io/qfilesystemengine_win.cpp index b1e218de9c..e4a7ea4891 100644 --- a/src/corelib/io/qfilesystemengine_win.cpp +++ b/src/corelib/io/qfilesystemengine_win.cpp @@ -612,13 +612,13 @@ QByteArray QFileSystemEngine::id(const QFileSystemEntry &entry) QByteArray result; const HANDLE handle = #ifndef Q_OS_WINRT - CreateFile((wchar_t*)entry.nativeFilePath().utf16(), GENERIC_READ, + CreateFile((wchar_t*)entry.nativeFilePath().utf16(), 0, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); #else // !Q_OS_WINRT - CreateFile2((const wchar_t*)entry.nativeFilePath().utf16(), GENERIC_READ, + CreateFile2((const wchar_t*)entry.nativeFilePath().utf16(), 0, FILE_SHARE_READ, OPEN_EXISTING, NULL); #endif // Q_OS_WINRT - if (handle) { + if (handle != INVALID_HANDLE_VALUE) { result = QOperatingSystemVersion::current() >= QOperatingSystemVersion::Windows8 ? fileIdWin8(handle) : fileId(handle); CloseHandle(handle); |