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:
Jarek Kobus
2022-09-19 08:27:41 +02:00
parent 5b0c2bcbf8
commit 3978cdde6c
3 changed files with 15 additions and 7 deletions

View File

@@ -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);