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:
Eike Ziller
2016-04-25 14:40:42 +02:00
parent cb08a44e7e
commit 967177d3d8
14 changed files with 54 additions and 126 deletions

View File

@@ -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,

View File

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