forked from qt-creator/qt-creator
Process: Get rid of ProcessInterpreter
Move it locally to the only one user: VcsCommand. For the future similar usages: use ProcessTask and tweak the DoneResult inside TaskDoneHandler. Change-Id: Icdffee7f1963f3ff377bfa6309e14bd1862a2c1f Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
@@ -831,8 +831,6 @@ public:
|
||||
emit (q->*signalName)();
|
||||
}
|
||||
|
||||
ProcessResult interpretExitCode(int exitCode);
|
||||
|
||||
bool waitForSignal(ProcessSignalType signalType, int msecs);
|
||||
Qt::ConnectionType connectionType() const;
|
||||
void sendControlSignal(ControlSignal controlSignal);
|
||||
@@ -848,7 +846,6 @@ public:
|
||||
ProcessResult m_result = ProcessResult::StartFailed;
|
||||
ChannelBuffer m_stdOut;
|
||||
ChannelBuffer m_stdErr;
|
||||
ExitCodeInterpreter m_exitCodeInterpreter;
|
||||
|
||||
int m_hangTimerCount = 0;
|
||||
int m_maxHangTimerCount = defaultMaxHangTimerCount;
|
||||
@@ -1113,15 +1110,6 @@ void ProcessPrivate::clearForRun()
|
||||
m_resultData = {};
|
||||
}
|
||||
|
||||
ProcessResult ProcessPrivate::interpretExitCode(int exitCode)
|
||||
{
|
||||
if (m_exitCodeInterpreter)
|
||||
return m_exitCodeInterpreter(exitCode);
|
||||
|
||||
// default:
|
||||
return exitCode ? ProcessResult::FinishedWithError : ProcessResult::FinishedWithSuccess;
|
||||
}
|
||||
|
||||
} // Internal
|
||||
|
||||
/*!
|
||||
@@ -1858,11 +1846,6 @@ void Process::setTimeOutMessageBoxEnabled(bool v)
|
||||
d->m_timeOutMessageBoxEnabled = v;
|
||||
}
|
||||
|
||||
void Process::setExitCodeInterpreter(const ExitCodeInterpreter &interpreter)
|
||||
{
|
||||
d->m_exitCodeInterpreter = interpreter;
|
||||
}
|
||||
|
||||
void Process::setWriteData(const QByteArray &writeData)
|
||||
{
|
||||
d->m_setup.m_writeData = writeData;
|
||||
@@ -2096,7 +2079,8 @@ void ProcessPrivate::handleDone(const ProcessResultData &data)
|
||||
if (m_resultData.m_error != QProcess::FailedToStart) {
|
||||
switch (m_resultData.m_exitStatus) {
|
||||
case QProcess::NormalExit:
|
||||
m_result = interpretExitCode(m_resultData.m_exitCode);
|
||||
m_result = m_resultData.m_exitCode ? ProcessResult::FinishedWithError
|
||||
: ProcessResult::FinishedWithSuccess;
|
||||
break;
|
||||
case QProcess::CrashExit:
|
||||
// Was hang detected before and killed?
|
||||
|
@@ -154,7 +154,6 @@ public:
|
||||
// TODO: We should specify the purpose of the codec, e.g. setCodecForStandardChannel()
|
||||
void setCodec(QTextCodec *c);
|
||||
void setTimeOutMessageBoxEnabled(bool);
|
||||
void setExitCodeInterpreter(const ExitCodeInterpreter &interpreter);
|
||||
|
||||
void setStdOutCallback(const TextChannelCallback &callback);
|
||||
void setStdOutLineCallback(const TextChannelCallback &callback);
|
||||
|
@@ -66,7 +66,6 @@ enum class ProcessResult {
|
||||
Hang
|
||||
};
|
||||
|
||||
using ExitCodeInterpreter = std::function<ProcessResult(int /*exitCode*/)>;
|
||||
using TextChannelCallback = std::function<void(const QString & /*text*/)>;
|
||||
|
||||
} // namespace Utils
|
||||
|
@@ -31,7 +31,7 @@ public:
|
||||
|
||||
Utils::Id vcsEditorKind(VcsCommandTag cmd) const override;
|
||||
QString vcsCommandString(VcsCommandTag cmd) const override;
|
||||
Utils::ExitCodeInterpreter exitCodeInterpreter(VcsCommandTag cmd) const override;
|
||||
VcsBase::ExitCodeInterpreter exitCodeInterpreter(VcsCommandTag cmd) const override;
|
||||
QStringList revisionSpec(const QString &revision) const override;
|
||||
StatusItem parseStatusLine(const QString &line) const override;
|
||||
|
||||
|
@@ -514,12 +514,6 @@ QString VcsBaseClient::vcsCommandString(VcsCommandTag cmd) const
|
||||
return {};
|
||||
}
|
||||
|
||||
ExitCodeInterpreter VcsBaseClient::exitCodeInterpreter(VcsCommandTag cmd) const
|
||||
{
|
||||
Q_UNUSED(cmd)
|
||||
return {};
|
||||
}
|
||||
|
||||
void VcsBaseClient::setDiffConfigCreator(ConfigCreator creator)
|
||||
{
|
||||
m_diffConfigCreator = std::move(creator);
|
||||
|
@@ -4,9 +4,9 @@
|
||||
#pragma once
|
||||
|
||||
#include "vcsbase_global.h"
|
||||
#include "vcsenums.h"
|
||||
|
||||
#include "vcsbaseclientsettings.h"
|
||||
#include "vcscommand.h"
|
||||
#include "vcsenums.h"
|
||||
|
||||
#include <utils/fileutils.h>
|
||||
#include <utils/id.h>
|
||||
@@ -32,7 +32,6 @@ namespace VcsBase {
|
||||
class CommandResult;
|
||||
class VcsBaseEditorConfig;
|
||||
class VcsBaseEditorWidget;
|
||||
class VcsCommand;
|
||||
|
||||
using CommandHandler = std::function<void(const CommandResult &)>;
|
||||
|
||||
@@ -61,7 +60,7 @@ public:
|
||||
const QStringList &args) const;
|
||||
|
||||
void enqueueJob(VcsCommand *cmd, const QStringList &args,
|
||||
const Utils::ExitCodeInterpreter &interpreter = {}) const;
|
||||
const ExitCodeInterpreter &interpreter = {}) const;
|
||||
|
||||
virtual Utils::Environment processEnvironment() const;
|
||||
|
||||
@@ -207,7 +206,7 @@ public:
|
||||
protected:
|
||||
virtual QString vcsCommandString(VcsCommandTag cmd) const;
|
||||
virtual Utils::Id vcsEditorKind(VcsCommandTag cmd) const = 0;
|
||||
virtual Utils::ExitCodeInterpreter exitCodeInterpreter(VcsCommandTag cmd) const;
|
||||
virtual ExitCodeInterpreter exitCodeInterpreter(VcsCommandTag) const { return {}; }
|
||||
|
||||
virtual QStringList revisionSpec(const QString &/*revision*/) const { return {}; }
|
||||
|
||||
|
@@ -29,6 +29,8 @@ namespace Internal { class VcsCommandPrivate; }
|
||||
|
||||
class VcsCommand;
|
||||
|
||||
using ExitCodeInterpreter = std::function<Utils::ProcessResult(int /*exitCode*/)>;
|
||||
|
||||
class VCSBASE_EXPORT CommandResult
|
||||
{
|
||||
public:
|
||||
@@ -70,7 +72,7 @@ public:
|
||||
|
||||
void addJob(const Utils::CommandLine &command, int timeoutS,
|
||||
const Utils::FilePath &workingDirectory = {},
|
||||
const Utils::ExitCodeInterpreter &interpreter = {});
|
||||
const ExitCodeInterpreter &interpreter = {});
|
||||
void start();
|
||||
|
||||
void addFlags(RunFlags f);
|
||||
|
Reference in New Issue
Block a user