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 <thiago.macieira@intel.com>
(cherry picked from commit b26ec1f5dde6ee77fbf6b96d3ec54cf93d18197e)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Mårten Nordheim 2024-04-15 17:34:51 +02:00 committed by Qt Cherry-pick Bot
parent c52120b7fb
commit acdef87d1c

View File

@ -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();