From acdef87d1c7f6b6ece633fb1865846aa83a2d3b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Mon, 15 Apr 2024 17:34:51 +0200 Subject: [PATCH] QSaveFile[win]: only use SetFileInformationByHandle when opened with DELETE SetFileInformationByHandle only works when we have opened the file with DELETE access. Since the code is shared with QTemporaryFile it is not necessarily always a given. Since it was anyway falling back to the old way of doing it it was not a problem, but it is cleaner to only use it when we know it will work. Change-Id: I3c744734d45272c41e49bb6971adf4f82213d97d Reviewed-by: Thiago Macieira (cherry picked from commit b26ec1f5dde6ee77fbf6b96d3ec54cf93d18197e) Reviewed-by: Qt Cherry-pick Bot --- src/corelib/io/qtemporaryfile.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/corelib/io/qtemporaryfile.cpp b/src/corelib/io/qtemporaryfile.cpp index 4bc21638f2d..7acfc7452c7 100644 --- a/src/corelib/io/qtemporaryfile.cpp +++ b/src/corelib/io/qtemporaryfile.cpp @@ -392,9 +392,11 @@ bool QTemporaryFileEngine::renameOverwrite(const QString &newName) return ok; } #ifdef Q_OS_WIN - if (d_func()->nativeRenameOverwrite(newName)) { - QFSFileEngine::close(); - return true; + if (flags & Win32NonShared) { + if (d_func()->nativeRenameOverwrite(newName)) { + QFSFileEngine::close(); + return true; + } } #endif QFSFileEngine::close();