diff --git a/src/plugins/vcsbase/vcsbasediffeditorcontroller.cpp b/src/plugins/vcsbase/vcsbasediffeditorcontroller.cpp index 04629f1e8b8..4f8d83ca948 100644 --- a/src/plugins/vcsbase/vcsbasediffeditorcontroller.cpp +++ b/src/plugins/vcsbase/vcsbasediffeditorcontroller.cpp @@ -50,7 +50,6 @@ public: FilePath m_vcsBinary; int m_vscTimeoutS; QString m_startupFile; - QString m_output; QString m_displayName; QPointer m_command; QFutureWatcher> *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 &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); diff --git a/src/plugins/vcsbase/vcscommand.cpp b/src/plugins/vcsbase/vcscommand.cpp index 8f9ef8f9b89..0e952a4d852 100644 --- a/src/plugins/vcsbase/vcscommand.cpp +++ b/src/plugins/vcsbase/vcscommand.cpp @@ -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; diff --git a/src/plugins/vcsbase/vcscommand.h b/src/plugins/vcsbase/vcscommand.h index cd20d349425..675b707f128 100644 --- a/src/plugins/vcsbase/vcscommand.h +++ b/src/plugins/vcsbase/vcscommand.h @@ -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 &);