forked from qt-creator/qt-creator
SynchronousProcess: Change exit code interpreter to function object
Change-Id: Ic48d4f5810f171c070f0980581fb6e45f6fe6b4a Reviewed-by: Orgad Shaneh <orgads@gmail.com> Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
@@ -30,7 +30,6 @@
|
||||
#include <vcsbase/vcsbaseeditor.h>
|
||||
#include <vcsbase/vcsbaseconstants.h>
|
||||
#include <vcsbase/vcsbaseeditorparameterwidget.h>
|
||||
#include <utils/synchronousprocess.h>
|
||||
|
||||
#include <QDir>
|
||||
#include <QFileInfo>
|
||||
@@ -43,22 +42,6 @@ using namespace VcsBase;
|
||||
namespace Cvs {
|
||||
namespace Internal {
|
||||
|
||||
class CvsDiffExitCodeInterpreter : public ExitCodeInterpreter
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CvsDiffExitCodeInterpreter(QObject *parent) : ExitCodeInterpreter(parent) {}
|
||||
SynchronousProcessResponse::Result interpretExitCode(int code) const;
|
||||
|
||||
};
|
||||
|
||||
SynchronousProcessResponse::Result CvsDiffExitCodeInterpreter::interpretExitCode(int code) const
|
||||
{
|
||||
if (code < 0 || code > 2)
|
||||
return SynchronousProcessResponse::FinishedError;
|
||||
return SynchronousProcessResponse::Finished;
|
||||
}
|
||||
|
||||
// Parameter widget controlling whitespace diff mode, associated with a parameter
|
||||
class CvsDiffParameterWidget : public VcsBaseEditorParameterWidget
|
||||
{
|
||||
@@ -111,14 +94,15 @@ Core::Id CvsClient::vcsEditorKind(VcsCommandTag cmd) const
|
||||
}
|
||||
}
|
||||
|
||||
ExitCodeInterpreter *CvsClient::exitCodeInterpreter(VcsCommandTag cmd, QObject *parent) const
|
||||
ExitCodeInterpreter CvsClient::exitCodeInterpreter(VcsCommandTag cmd) const
|
||||
{
|
||||
switch (cmd) {
|
||||
case DiffCommand:
|
||||
return new CvsDiffExitCodeInterpreter(parent);
|
||||
default:
|
||||
return 0;
|
||||
if (cmd == DiffCommand) {
|
||||
return [](int code) {
|
||||
return (code < 0 || code > 2) ? SynchronousProcessResponse::FinishedError
|
||||
: SynchronousProcessResponse::Finished;
|
||||
};
|
||||
}
|
||||
return Utils::defaultExitCodeInterpreter;
|
||||
}
|
||||
|
||||
void CvsClient::diff(const QString &workingDir, const QStringList &files,
|
||||
|
||||
@@ -49,7 +49,7 @@ public:
|
||||
StatusItem parseStatusLine(const QString &line) const override;
|
||||
|
||||
protected:
|
||||
Utils::ExitCodeInterpreter *exitCodeInterpreter(VcsCommandTag cmd, QObject *parent) const override;
|
||||
Utils::ExitCodeInterpreter exitCodeInterpreter(VcsCommandTag cmd) const override;
|
||||
Core::Id vcsEditorKind(VcsCommandTag cmd) const override;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user