Commit 82d312aa authored by Andre Hartmann's avatar Andre Hartmann Committed by Erik Verbruggen

Fix encoding of non-opened include files.

The old implementation readed the file and converted the QString toUtf8,
which seems wrong. Now use Creators default encoding.

This fixes at least wrong macro offsets that leaded to highlighting
errors in Find Usages, if there were non-ASCII characters before the
macro definition.

This should also partially solve QTCREATORBUG-7122.

Change-Id: Ic4a5add5f4769bd3d5b62fc2d67598e7abf352d9
Reviewed-by: default avatarErik Verbruggen <>
parent 480163ef
......@@ -366,9 +366,11 @@ bool CppPreprocessor::includeFile(const QString &absoluteFilePath, QString *resu
QFile file(absoluteFilePath);
if ( | QFile::Text)) {
QTextCodec *defaultCodec = Core::EditorManager::instance()->defaultTextCodec();
QTextStream stream(&file);
const QString contents = stream.readAll();
*result = contents.toUtf8();
if (result)
*result = stream.readAll();
return true;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment