Commit 58f8d43f authored by Yuchen Deng's avatar Yuchen Deng Committed by Tobias Hunger
Browse files

Git: Fix error encoding if the source file not exist



Change-Id: Ia98195f966e79d65f1947c638cb9aacfb9b2f309
Reviewed-by: default avatarTobias Hunger <tobias.hunger@nokia.com>
parent 62afcd67
......@@ -408,7 +408,7 @@ VcsBase::VcsBaseEditorWidget *GitClient::createVcsEditor(const Core::Id &id,
QTC_ASSERT(rc, return 0);
rc->setSource(source);
if (codecType == CodecSource) {
rc->setCodec(VcsBase::VcsBaseEditorWidget::getCodec(source));
rc->setCodec(getSourceCodec(source));
} else if (codecType == CodecLogOutput) {
QString encodingName = readConfigValue(source, QLatin1String("i18n.logOutputEncoding"));
if (encodingName.isEmpty())
......@@ -675,6 +675,16 @@ void GitClient::slotBlameRevisionRequested(const QString &source, QString change
blame(fi.absolutePath(), QStringList(), fi.fileName(), change, lineNumber);
}
QTextCodec *GitClient::getSourceCodec(const QString &file) const
{
if (QFileInfo(file).isFile())
return VcsBase::VcsBaseEditorWidget::getCodec(file);
QString encodingName = readConfigValue(file, QLatin1String("gui.encoding"));
if (encodingName.isEmpty())
encodingName = QLatin1String("utf-8");
return QTextCodec::codecForName(encodingName.toLocal8Bit());
}
void GitClient::blame(const QString &workingDirectory,
const QStringList &args,
const QString &fileName,
......
......@@ -233,6 +233,7 @@ private slots:
void slotBlameRevisionRequested(const QString &source, QString change, int lineNumber);
private:
QTextCodec *getSourceCodec(const QString &file) const;
VcsBase::VcsBaseEditorWidget *findExistingVCSEditor(const char *registerDynamicProperty,
const QString &dynamicPropertyValue) const;
enum CodecType { CodecSource, CodecLogOutput, CodecNone };
......
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