forked from qt-creator/qt-creator
Utils: Add env to disable special win32 code
Change-Id: I450152a4d049461b98416fa61a9a1e7082625ecc Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
This commit is contained in:
@@ -129,7 +129,10 @@ bool SaveFile::commit()
|
||||
|
||||
FilePath finalFileName = m_finalFilePath.resolveSymlinks();
|
||||
|
||||
if constexpr (HostOsInfo::isWindowsHost() && !m_finalFilePath.needsDevice()) {
|
||||
if constexpr (HostOsInfo::isWindowsHost()) {
|
||||
static const bool disableWinSpecialCode = !qEnvironmentVariableIsEmpty(
|
||||
"QTC_DISABLE_SPECIAL_WIN_SAVEFILE");
|
||||
if (!m_finalFilePath.needsDevice() && !disableWinSpecialCode) {
|
||||
// Release the file lock
|
||||
m_tempFile.reset();
|
||||
bool result = ReplaceFile(
|
||||
@@ -153,7 +156,8 @@ bool SaveFile::commit()
|
||||
result = MoveFileEx(
|
||||
fileName().toStdWString().data(),
|
||||
finalFileName.nativePath().toStdWString().data(),
|
||||
MOVEFILE_COPY_ALLOWED | MOVEFILE_REPLACE_EXISTING | MOVEFILE_WRITE_THROUGH);
|
||||
MOVEFILE_COPY_ALLOWED | MOVEFILE_REPLACE_EXISTING
|
||||
| MOVEFILE_WRITE_THROUGH);
|
||||
if (!result)
|
||||
replaceErrorCode = GetLastError();
|
||||
}
|
||||
@@ -177,7 +181,9 @@ bool SaveFile::commit()
|
||||
}
|
||||
|
||||
return result;
|
||||
} else {
|
||||
}
|
||||
}
|
||||
|
||||
const QString backupName = finalFileName.toFSPathString() + '~';
|
||||
|
||||
// Back up current file.
|
||||
@@ -200,8 +206,7 @@ bool SaveFile::commit()
|
||||
// return false while keeping the error string from last rename call.
|
||||
m_tempFile->filePath().removeFile();
|
||||
setErrorString(renameResult.error());
|
||||
QFile::rename(
|
||||
backupName, finalFileName.toFSPathString()); // rollback to backup if possible ...
|
||||
QFile::rename(backupName, finalFileName.toFSPathString()); // rollback to backup if possible ...
|
||||
return false; // ... or keep the backup copy at least
|
||||
}
|
||||
|
||||
@@ -209,7 +214,6 @@ bool SaveFile::commit()
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
void SaveFile::initializeUmask()
|
||||
{
|
||||
|
Reference in New Issue
Block a user