forked from qt-creator/qt-creator
VcsCommand: Add std channel getters
Conform to QtcProcess interface and provide cleanedStdOut() and cleanedStdErr() getters, to be called after the process finished. Use cleanedStdOut() inside DiffEditorController for getting the output after the process finished instead of connecting to stdOutText() signal. Change-Id: I7ba3735b0ab2167ac1f3b0954dd5dc9553910aac Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
@@ -50,7 +50,6 @@ public:
|
||||
FilePath m_vcsBinary;
|
||||
int m_vscTimeoutS;
|
||||
QString m_startupFile;
|
||||
QString m_output;
|
||||
QString m_displayName;
|
||||
QPointer<VcsCommand> m_command;
|
||||
QFutureWatcher<QList<FileData>> *m_processWatcher = nullptr;
|
||||
@@ -107,12 +106,11 @@ void VcsBaseDiffEditorControllerPrivate::cancelReload()
|
||||
delete m_processWatcher;
|
||||
m_processWatcher = nullptr;
|
||||
}
|
||||
|
||||
m_output = QString();
|
||||
}
|
||||
|
||||
void VcsBaseDiffEditorControllerPrivate::commandFinished(bool success)
|
||||
{
|
||||
const QString output = m_command->cleanedStdOut();
|
||||
// Don't delete here, as it is called from command finished signal.
|
||||
// Clear it only, as we may call runCommand() again from inside processCommandOutput overload.
|
||||
m_command.clear();
|
||||
@@ -123,8 +121,7 @@ void VcsBaseDiffEditorControllerPrivate::commandFinished(bool success)
|
||||
return;
|
||||
}
|
||||
|
||||
// Pass a copy of m_output since processDiff() cleans the m_output
|
||||
q->processCommandOutput(QString(m_output));
|
||||
q->processCommandOutput(output);
|
||||
}
|
||||
|
||||
/////////////////////
|
||||
@@ -151,8 +148,6 @@ void VcsBaseDiffEditorController::runCommand(const QList<QStringList> &args, uns
|
||||
d->m_command = VcsBaseClient::createVcsCommand(workingDirectory(), d->m_processEnvironment);
|
||||
d->m_command->setDisplayName(d->m_displayName);
|
||||
d->m_command->setCodec(codec ? codec : EditorManager::defaultTextCodec());
|
||||
connect(d->m_command.data(), &VcsCommand::stdOutText,
|
||||
this, [this](const QString &output) { d->m_output = output; });
|
||||
connect(d->m_command.data(), &VcsCommand::finished,
|
||||
this, [this](bool success) { d->commandFinished(success); });
|
||||
d->m_command->addFlags(flags);
|
||||
|
||||
@@ -372,6 +372,16 @@ void VcsCommand::cancel()
|
||||
emit terminate();
|
||||
}
|
||||
|
||||
QString VcsCommand::cleanedStdOut() const
|
||||
{
|
||||
return d->m_stdOut;
|
||||
}
|
||||
|
||||
QString VcsCommand::cleanedStdErr() const
|
||||
{
|
||||
return d->m_stdErr;
|
||||
}
|
||||
|
||||
CommandResult VcsCommand::runCommand(const CommandLine &command, int timeoutS)
|
||||
{
|
||||
QtcProcess process;
|
||||
|
||||
@@ -116,6 +116,9 @@ public:
|
||||
CommandResult runCommand(const Utils::CommandLine &command, int timeoutS = 10);
|
||||
void cancel();
|
||||
|
||||
QString cleanedStdOut() const;
|
||||
QString cleanedStdErr() const;
|
||||
|
||||
signals:
|
||||
void stdOutText(const QString &);
|
||||
void stdErrText(const QString &);
|
||||
|
||||
Reference in New Issue
Block a user