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

@@ -31,7 +31,6 @@
#include <vcsbase/vcsbaseplugin.h>
#include <vcsbase/vcsoutputwindow.h>
#include <vcsbase/vcsbaseeditorparameterwidget.h>
#include <utils/synchronousprocess.h>
#include <QDir>
#include <QFileInfo>
@@ -44,21 +43,6 @@ using namespace VcsBase;
namespace Bazaar {
namespace Internal {
class BazaarDiffExitCodeInterpreter : public ExitCodeInterpreter
{
Q_OBJECT
public:
BazaarDiffExitCodeInterpreter(QObject *parent) : ExitCodeInterpreter(parent) {}
SynchronousProcessResponse::Result interpretExitCode(int code) const;
};
SynchronousProcessResponse::Result BazaarDiffExitCodeInterpreter::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 BazaarDiffParameterWidget : public VcsBaseEditorParameterWidget
{
@@ -240,14 +224,15 @@ QString BazaarClient::vcsCommandString(VcsCommandTag cmd) const
}
}
ExitCodeInterpreter *BazaarClient::exitCodeInterpreter(VcsCommandTag cmd, QObject *parent) const
ExitCodeInterpreter BazaarClient::exitCodeInterpreter(VcsCommandTag cmd) const
{
switch (cmd) {
case DiffCommand:
return new BazaarDiffExitCodeInterpreter(parent);
default:
return 0;
if (cmd == DiffCommand) {
return [](int code) {
return (code < 0 || code > 2) ? SynchronousProcessResponse::FinishedError
: SynchronousProcessResponse::Finished;
};
}
return Utils::defaultExitCodeInterpreter;
}
QStringList BazaarClient::revisionSpec(const QString &revision) const