forked from qt-creator/qt-creator
Utils: Don't expose Utils::defaultExitCodeInterpreter
Instead, make its behavior implicit if none is given. Change-Id: I3c1a054751a0afe22d0f40a2fed6dd00b5aef205 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -112,6 +112,8 @@ public:
|
|||||||
void slotError(QProcess::ProcessError);
|
void slotError(QProcess::ProcessError);
|
||||||
void clearForRun();
|
void clearForRun();
|
||||||
|
|
||||||
|
SynchronousProcessResponse::Result interpretExitCode(int exitCode);
|
||||||
|
|
||||||
QtcProcess *q;
|
QtcProcess *q;
|
||||||
QTextCodec *m_codec = QTextCodec::codecForLocale();
|
QTextCodec *m_codec = QTextCodec::codecForLocale();
|
||||||
QTimer m_timer;
|
QTimer m_timer;
|
||||||
@@ -120,7 +122,7 @@ public:
|
|||||||
FilePath m_binary;
|
FilePath m_binary;
|
||||||
ChannelBuffer m_stdOut;
|
ChannelBuffer m_stdOut;
|
||||||
ChannelBuffer m_stdErr;
|
ChannelBuffer m_stdErr;
|
||||||
ExitCodeInterpreter m_exitCodeInterpreter = defaultExitCodeInterpreter;
|
ExitCodeInterpreter m_exitCodeInterpreter;
|
||||||
|
|
||||||
int m_hangTimerCount = 0;
|
int m_hangTimerCount = 0;
|
||||||
int m_maxHangTimerCount = defaultMaxHangTimerCount;
|
int m_maxHangTimerCount = defaultMaxHangTimerCount;
|
||||||
@@ -142,6 +144,16 @@ void QtcProcessPrivate::clearForRun()
|
|||||||
m_binary = {};
|
m_binary = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SynchronousProcessResponse::Result QtcProcessPrivate::interpretExitCode(int exitCode)
|
||||||
|
{
|
||||||
|
if (m_exitCodeInterpreter)
|
||||||
|
return m_exitCodeInterpreter(exitCode);
|
||||||
|
|
||||||
|
// default:
|
||||||
|
return exitCode ? SynchronousProcessResponse::FinishedError
|
||||||
|
: SynchronousProcessResponse::Finished;
|
||||||
|
}
|
||||||
|
|
||||||
} // Internal
|
} // Internal
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -633,12 +645,6 @@ QTCREATOR_UTILS_EXPORT QDebug operator<<(QDebug str, const SynchronousProcessRes
|
|||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
SynchronousProcessResponse::Result defaultExitCodeInterpreter(int code)
|
|
||||||
{
|
|
||||||
return code ? SynchronousProcessResponse::FinishedError
|
|
||||||
: SynchronousProcessResponse::Finished;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ChannelBuffer::clearForRun()
|
void ChannelBuffer::clearForRun()
|
||||||
{
|
{
|
||||||
rawDataPos = 0;
|
rawDataPos = 0;
|
||||||
@@ -732,7 +738,6 @@ void QtcProcess::setTimeOutMessageBoxEnabled(bool v)
|
|||||||
|
|
||||||
void QtcProcess::setExitCodeInterpreter(const ExitCodeInterpreter &interpreter)
|
void QtcProcess::setExitCodeInterpreter(const ExitCodeInterpreter &interpreter)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(interpreter, return);
|
|
||||||
d->m_exitCodeInterpreter = interpreter;
|
d->m_exitCodeInterpreter = interpreter;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -867,7 +872,7 @@ SynchronousProcessResponse QtcProcess::runBlocking(const CommandLine &cmd)
|
|||||||
if (exitStatus() != QProcess::NormalExit)
|
if (exitStatus() != QProcess::NormalExit)
|
||||||
d->m_result.result = SynchronousProcessResponse::TerminatedAbnormally;
|
d->m_result.result = SynchronousProcessResponse::TerminatedAbnormally;
|
||||||
else
|
else
|
||||||
d->m_result.result = d->m_exitCodeInterpreter(d->m_result.exitCode);
|
d->m_result.result = d->interpretExitCode(d->m_result.exitCode);
|
||||||
}
|
}
|
||||||
d->m_stdOut.append(readAllStandardOutput(), false);
|
d->m_stdOut.append(readAllStandardOutput(), false);
|
||||||
d->m_stdErr.append(readAllStandardError(), false);
|
d->m_stdErr.append(readAllStandardError(), false);
|
||||||
@@ -916,7 +921,7 @@ void QtcProcessPrivate::slotFinished(int exitCode, QProcess::ExitStatus e)
|
|||||||
|
|
||||||
switch (e) {
|
switch (e) {
|
||||||
case QProcess::NormalExit:
|
case QProcess::NormalExit:
|
||||||
m_result.result = m_exitCodeInterpreter(exitCode);
|
m_result.result = interpretExitCode(exitCode);
|
||||||
m_result.exitCode = exitCode;
|
m_result.exitCode = exitCode;
|
||||||
break;
|
break;
|
||||||
case QProcess::CrashExit:
|
case QProcess::CrashExit:
|
||||||
|
@@ -147,8 +147,6 @@ private:
|
|||||||
|
|
||||||
QTCREATOR_UTILS_EXPORT QDebug operator<<(QDebug str, const SynchronousProcessResponse &);
|
QTCREATOR_UTILS_EXPORT QDebug operator<<(QDebug str, const SynchronousProcessResponse &);
|
||||||
|
|
||||||
QTCREATOR_UTILS_EXPORT SynchronousProcessResponse::Result defaultExitCodeInterpreter(int code);
|
|
||||||
|
|
||||||
class QTCREATOR_UTILS_EXPORT SynchronousProcess : public QtcProcess
|
class QTCREATOR_UTILS_EXPORT SynchronousProcess : public QtcProcess
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@@ -108,10 +108,10 @@ public:
|
|||||||
|
|
||||||
void addJob(const CommandLine &command,
|
void addJob(const CommandLine &command,
|
||||||
const QString &workingDirectory = QString(),
|
const QString &workingDirectory = QString(),
|
||||||
const ExitCodeInterpreter &interpreter = defaultExitCodeInterpreter);
|
const ExitCodeInterpreter &interpreter = {});
|
||||||
void addJob(const CommandLine &command, int timeoutS,
|
void addJob(const CommandLine &command, int timeoutS,
|
||||||
const QString &workingDirectory = QString(),
|
const QString &workingDirectory = QString(),
|
||||||
const ExitCodeInterpreter &interpreter = defaultExitCodeInterpreter);
|
const ExitCodeInterpreter &interpreter = {});
|
||||||
void execute(); // Execute tasks asynchronously!
|
void execute(); // Execute tasks asynchronously!
|
||||||
void abort();
|
void abort();
|
||||||
bool lastExecutionSuccess() const;
|
bool lastExecutionSuccess() const;
|
||||||
@@ -145,7 +145,7 @@ public:
|
|||||||
virtual SynchronousProcessResponse runCommand(const CommandLine &command,
|
virtual SynchronousProcessResponse runCommand(const CommandLine &command,
|
||||||
int timeoutS,
|
int timeoutS,
|
||||||
const QString &workingDirectory = QString(),
|
const QString &workingDirectory = QString(),
|
||||||
const ExitCodeInterpreter &interpreter = defaultExitCodeInterpreter);
|
const ExitCodeInterpreter &interpreter = {});
|
||||||
|
|
||||||
void cancel();
|
void cancel();
|
||||||
|
|
||||||
@@ -170,12 +170,12 @@ private:
|
|||||||
SynchronousProcessResponse runFullySynchronous(const CommandLine &cmd,
|
SynchronousProcessResponse runFullySynchronous(const CommandLine &cmd,
|
||||||
QSharedPointer<OutputProxy> proxy,
|
QSharedPointer<OutputProxy> proxy,
|
||||||
int timeoutS, const QString &workingDirectory,
|
int timeoutS, const QString &workingDirectory,
|
||||||
const ExitCodeInterpreter &interpreter = defaultExitCodeInterpreter);
|
const ExitCodeInterpreter &interpreter = {});
|
||||||
// Run with an event loop. Signals will be delivered.
|
// Run with an event loop. Signals will be delivered.
|
||||||
SynchronousProcessResponse runSynchronous(const CommandLine &cmd,
|
SynchronousProcessResponse runSynchronous(const CommandLine &cmd,
|
||||||
QSharedPointer<OutputProxy> proxy,
|
QSharedPointer<OutputProxy> proxy,
|
||||||
int timeoutS, const QString &workingDirectory,
|
int timeoutS, const QString &workingDirectory,
|
||||||
const ExitCodeInterpreter &interpreter = defaultExitCodeInterpreter);
|
const ExitCodeInterpreter &interpreter = {});
|
||||||
|
|
||||||
class Internal::ShellCommandPrivate *const d;
|
class Internal::ShellCommandPrivate *const d;
|
||||||
};
|
};
|
||||||
|
@@ -235,7 +235,7 @@ ExitCodeInterpreter BazaarClient::exitCodeInterpreter(VcsCommandTag cmd) const
|
|||||||
: SynchronousProcessResponse::Finished;
|
: SynchronousProcessResponse::Finished;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
return Utils::defaultExitCodeInterpreter;
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList BazaarClient::revisionSpec(const QString &revision) const
|
QStringList BazaarClient::revisionSpec(const QString &revision) const
|
||||||
|
@@ -208,7 +208,7 @@ public:
|
|||||||
: SynchronousProcessResponse::Finished;
|
: SynchronousProcessResponse::Finished;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
return Utils::defaultExitCodeInterpreter;
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
Utils::Id vcsEditorKind(VcsCommandTag cmd) const override
|
Utils::Id vcsEditorKind(VcsCommandTag cmd) const override
|
||||||
|
@@ -518,7 +518,7 @@ QString VcsBaseClient::vcsCommandString(VcsCommandTag cmd) const
|
|||||||
ExitCodeInterpreter VcsBaseClient::exitCodeInterpreter(VcsCommandTag cmd) const
|
ExitCodeInterpreter VcsBaseClient::exitCodeInterpreter(VcsCommandTag cmd) const
|
||||||
{
|
{
|
||||||
Q_UNUSED(cmd)
|
Q_UNUSED(cmd)
|
||||||
return Utils::defaultExitCodeInterpreter;
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
void VcsBaseClient::setDiffConfigCreator(ConfigCreator creator)
|
void VcsBaseClient::setDiffConfigCreator(ConfigCreator creator)
|
||||||
|
@@ -41,7 +41,6 @@
|
|||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
class QFileInfo;
|
class QFileInfo;
|
||||||
class QProcessEnvironment;
|
|
||||||
class QToolBar;
|
class QToolBar;
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
@@ -82,7 +81,7 @@ public:
|
|||||||
|
|
||||||
void enqueueJob(VcsCommand *cmd, const QStringList &args,
|
void enqueueJob(VcsCommand *cmd, const QStringList &args,
|
||||||
const QString &workingDirectory = QString(),
|
const QString &workingDirectory = QString(),
|
||||||
const Utils::ExitCodeInterpreter &interpreter = Utils::defaultExitCodeInterpreter) const;
|
const Utils::ExitCodeInterpreter &interpreter = {}) const;
|
||||||
|
|
||||||
virtual Utils::Environment processEnvironment() const;
|
virtual Utils::Environment processEnvironment() const;
|
||||||
|
|
||||||
|
@@ -48,7 +48,7 @@ public:
|
|||||||
Utils::SynchronousProcessResponse runCommand(const Utils::CommandLine &command,
|
Utils::SynchronousProcessResponse runCommand(const Utils::CommandLine &command,
|
||||||
int timeoutS,
|
int timeoutS,
|
||||||
const QString &workDirectory = QString(),
|
const QString &workDirectory = QString(),
|
||||||
const Utils::ExitCodeInterpreter &interpreter = Utils::defaultExitCodeInterpreter) override;
|
const Utils::ExitCodeInterpreter &interpreter = {}) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void emitRepositoryChanged(const QString &workingDirectory);
|
void emitRepositoryChanged(const QString &workingDirectory);
|
||||||
|
Reference in New Issue
Block a user