diff --git a/src/libs/utils/textfileformat.cpp b/src/libs/utils/textfileformat.cpp index afd4e62e830..ea682edae95 100644 --- a/src/libs/utils/textfileformat.cpp +++ b/src/libs/utils/textfileformat.cpp @@ -302,14 +302,11 @@ bool TextFileFormat::writeFile(const QString &fileName, QString plainText, QStri QTC_ASSERT(codec, return false); // Does the user want CRLF? If that is native, - // let QFile do the work, else manually add. + // do net let QFile do the work, because it replaces the line ending after the text was encoded, + // and this could lead to undecodable file contents. QIODevice::OpenMode fileMode = QIODevice::NotOpen; - if (lineTerminationMode == CRLFLineTerminator) { - if (NativeLineTerminator == CRLFLineTerminator) - fileMode |= QIODevice::Text; - else - plainText.replace(QLatin1Char('\n'), QLatin1String("\r\n")); - } + if (lineTerminationMode == CRLFLineTerminator) + plainText.replace(QLatin1Char('\n'), QLatin1String("\r\n")); FileSaver saver(fileName, fileMode); if (!saver.hasError()) {