From b269d0b5227a8471011cd1530adc99bfeaa500d7 Mon Sep 17 00:00:00 2001 From: Floris Bos Date: Tue, 10 Mar 2020 16:40:31 +0100 Subject: [PATCH] Windows: ignore errors from FlushFileBuffers() Appereantly the function does not work as advertised on Windows 7. Do call it, but ignore errors. Hopefully any real write errors, will be detected when reading back image instead. --- windows/winfile.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/windows/winfile.cpp b/windows/winfile.cpp index fc23636..105e2ad 100644 --- a/windows/winfile.cpp +++ b/windows/winfile.cpp @@ -30,7 +30,7 @@ bool WinFile::open(QIODevice::OpenMode) for (int attempt = 0; attempt < 20; attempt++) { - _h = CreateFileA(n.data(), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + _h = CreateFileA(n.data(), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL); if (_h != INVALID_HANDLE_VALUE) break; @@ -143,8 +143,9 @@ bool WinFile::flush() { if (!FlushFileBuffers(_h)) { - _lasterror = qt_error_string(); - return false; + // Windows 7 does not support flush properly, so ignore errors + //_lasterror = qt_error_string(); + //return false; } return true;