Commit 8e1f24a6 authored by Yuchen Deng's avatar Yuchen Deng Committed by Tobias Hunger
Browse files

Git: Fix error encoding of output text in some case



Change-Id: I0bf4269266e725d567b3ff69e4a3ea202911b3ab
Reviewed-by: default avatarTobias Hunger <tobias.hunger@nokia.com>
parent 5fede0d4
......@@ -51,6 +51,7 @@
#include <coreplugin/id.h>
#include <coreplugin/filemanager.h>
#include <coreplugin/iversioncontrol.h>
#include <coreplugin/variablemanager.h>
#include <texteditor/itexteditor.h>
#include <utils/qtcassert.h>
......@@ -337,6 +338,11 @@ static inline QString msgParseFilesFailed()
return GitClient::tr("Cannot parse the file output.");
}
static inline QString currentDocumentPath()
{
return Core::VariableManager::instance()->value("CurrentDocument:Path");
}
// ---------------- GitClient
const char *GitClient::stashNamePrefix = "stash@{";
......@@ -683,6 +689,18 @@ void GitClient::slotBlameRevisionRequested(const QString &source, QString change
blame(fi.absolutePath(), QStringList(), fi.fileName(), change, lineNumber);
}
void GitClient::appendOutputData(const QByteArray &data) const
{
const QTextCodec *codec = getSourceCodec(currentDocumentPath());
outputWindow()->appendData(codec->toUnicode(data).toLocal8Bit());
}
void GitClient::appendOutputDataSilently(const QByteArray &data) const
{
const QTextCodec *codec = getSourceCodec(currentDocumentPath());
outputWindow()->appendDataSilently(codec->toUnicode(data).toLocal8Bit());
}
QTextCodec *GitClient::getSourceCodec(const QString &file) const
{
if (QFileInfo(file).isFile())
......@@ -1343,9 +1361,9 @@ VcsBase::Command *GitClient::createCommand(const QString &workingDirectory,
connect(command, SIGNAL(finished(bool,int,QVariant)), editor, SLOT(commandFinishedGotoLine(bool,int,QVariant)));
if (useOutputToWindow) {
if (editor) // assume that the commands output is the important thing
connect(command, SIGNAL(outputData(QByteArray)), outputWindow(), SLOT(appendDataSilently(QByteArray)));
connect(command, SIGNAL(outputData(QByteArray)), this, SLOT(appendOutputDataSilently(QByteArray)));
else
connect(command, SIGNAL(outputData(QByteArray)), outputWindow(), SLOT(appendData(QByteArray)));
connect(command, SIGNAL(outputData(QByteArray)), this, SLOT(appendOutputData(QByteArray)));
} else {
if (editor)
connect(command, SIGNAL(outputData(QByteArray)), editor, SLOT(setPlainTextDataFiltered(QByteArray)));
......
......@@ -231,6 +231,8 @@ public slots:
private slots:
void slotBlameRevisionRequested(const QString &source, QString change, int lineNumber);
void appendOutputData(const QByteArray &data) const;
void appendOutputDataSilently(const QByteArray &data) const;
private:
QTextCodec *getSourceCodec(const QString &file) const;
......
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