forked from qt-creator/qt-creator
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:
@@ -1203,7 +1203,8 @@ QPair<ProFile *, QStringList> QmakePriFileNode::readProFile(const QString &file)
|
|||||||
QmakeProject::proFileParseError(reader.errorString());
|
QmakeProject::proFileParseError(reader.errorString());
|
||||||
return qMakePair(includeFile, lines);
|
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'));
|
lines = contents.split(QLatin1Char('\n'));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1320,7 +1321,8 @@ void QmakePriFileNode::save(const QStringList &lines)
|
|||||||
{
|
{
|
||||||
FileChangeBlocker changeGuard(m_projectFilePath.toString());
|
FileChangeBlocker changeGuard(m_projectFilePath.toString());
|
||||||
FileSaver saver(m_projectFilePath.toString(), QIODevice::Text);
|
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());
|
saver.finalize(Core::ICore::mainWindow());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user