QmakeProjectManager: Use "Default encoding" for mechanized editing

When performing mechanized editing on .pro/.pri files, until now, Qt
Creator reloaded and restored the file with [from|to]Local8Bit.

That broke #comments in unicode.

This change implements that the the "Default encoding" from the text
editor options is used instead.

Task-number: QTCREATORBUG-10274
Change-Id: I783fc3a2c6a2638e4603ced2eef25c2a3998e2c1
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
Alessandro Portale
2016-11-25 18:04:33 +01:00
parent c390c716d1
commit ebf8c1eaf0

View File

@@ -1203,7 +1203,8 @@ QPair<ProFile *, QStringList> QmakePriFileNode::readProFile(const QString &file)
QmakeProject::proFileParseError(reader.errorString());
return qMakePair(includeFile, lines);
}
contents = QString::fromLocal8Bit(reader.data());
const QTextCodec *codec = Core::EditorManager::defaultTextCodec();
contents = codec->toUnicode(reader.data());
lines = contents.split(QLatin1Char('\n'));
}
@@ -1320,7 +1321,8 @@ void QmakePriFileNode::save(const QStringList &lines)
{
FileChangeBlocker changeGuard(m_projectFilePath.toString());
FileSaver saver(m_projectFilePath.toString(), QIODevice::Text);
saver.write(lines.join(QLatin1Char('\n')).toLocal8Bit());
const QTextCodec *codec = Core::EditorManager::defaultTextCodec();
saver.write(codec->fromUnicode(lines.join(QLatin1Char('\n'))));
saver.finalize(Core::ICore::mainWindow());
}