Utils: Fix line ending conversion in FileReader

FilePath::fileContents always uses "binary" mode when reading files.

FileReader::fetch previously used QFile with QIODevice::Text mode to
read (local) files, which converts \r\n to \n. This patch re-introduces
the conversion.

Fixes: QTCREATORBUG-29040
Change-Id: I0a16b056bea456512e6526497b725c73b0a1bd11
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
Marcus Tillmanns
2023-04-24 16:31:22 +02:00
parent 05f80a132d
commit 2e384d9c12

View File

@@ -62,6 +62,10 @@ bool FileReader::fetch(const FilePath &filePath, QIODevice::OpenMode mode)
return false; return false;
} }
m_data = *contents; m_data = *contents;
if (mode & QIODevice::Text)
m_data = m_data.replace("\r\n", "\n");
return true; return true;
} }