forked from qt-creator/qt-creator
Utils: Drop QProcess specific parameters from QtcProcess::finished()
Mid-term plan is to concentrate on use of QtcProcess::result() instead which is a bit more system-agnostic. There's quite a bit of potential for downstream cleanup by re-using QtcProcess::exitMessage() now. Change-Id: I3806b3f5933d96e64b7cfb18cc6c52823fddcbcd Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -224,7 +224,7 @@ Archive *Archive::unarchive(const FilePath &src, const FilePath &dest)
|
||||
archive->m_process,
|
||||
&QtcProcess::finished,
|
||||
archive,
|
||||
[archive](int, QProcess::ExitStatus) {
|
||||
[archive] {
|
||||
if (!archive->m_process)
|
||||
return;
|
||||
archive->finished(archive->m_process->result() == QtcProcess::FinishedWithSuccess);
|
||||
|
@@ -192,6 +192,7 @@ public:
|
||||
QTimer m_timer;
|
||||
QEventLoop m_eventLoop;
|
||||
QtcProcess::Result m_result = QtcProcess::StartFailed;
|
||||
QProcess::ExitStatus m_exitStatus = QProcess::NormalExit;
|
||||
int m_exitCode = -1;
|
||||
FilePath m_binary;
|
||||
ChannelBuffer m_stdOut;
|
||||
@@ -1079,13 +1080,14 @@ void QtcProcessPrivate::slotTimeout()
|
||||
}
|
||||
}
|
||||
|
||||
void QtcProcessPrivate::slotFinished(int exitCode, QProcess::ExitStatus e)
|
||||
void QtcProcessPrivate::slotFinished(int exitCode, QProcess::ExitStatus status)
|
||||
{
|
||||
if (debug)
|
||||
qDebug() << Q_FUNC_INFO << exitCode << e;
|
||||
qDebug() << Q_FUNC_INFO << exitCode << status;
|
||||
m_hangTimerCount = 0;
|
||||
m_exitStatus = status;
|
||||
|
||||
switch (e) {
|
||||
switch (status) {
|
||||
case QProcess::NormalExit:
|
||||
m_result = interpretExitCode(exitCode);
|
||||
m_exitCode = exitCode;
|
||||
@@ -1098,7 +1100,7 @@ void QtcProcessPrivate::slotFinished(int exitCode, QProcess::ExitStatus e)
|
||||
break;
|
||||
}
|
||||
m_eventLoop.quit();
|
||||
emit q->finished(m_exitCode, e);
|
||||
emit q->finished();
|
||||
}
|
||||
|
||||
void QtcProcessPrivate::slotError(QProcess::ProcessError e)
|
||||
|
@@ -173,7 +173,7 @@ public:
|
||||
|
||||
signals:
|
||||
void started();
|
||||
void finished(int exitCode, QProcess::ExitStatus exitStatus);
|
||||
void finished();
|
||||
void errorOccurred(QProcess::ProcessError error);
|
||||
void stateChanged(QProcess::ProcessState state);
|
||||
|
||||
|
@@ -730,15 +730,13 @@ void AndroidSettingsWidget::downloadOpenSslRepo(const bool silent)
|
||||
openButton->deleteLater();
|
||||
};
|
||||
|
||||
connect(gitCloner, &QtcProcess::finished,
|
||||
m_ui.openSslPathChooser,
|
||||
[=](int exitCode, QProcess::ExitStatus exitStatus) {
|
||||
connect(gitCloner, &QtcProcess::finished, [=] {
|
||||
openSslProgressDialog->close();
|
||||
validateOpenSsl();
|
||||
m_ui.openSslPathChooser->triggerChanged(); // After cloning, the path exists
|
||||
|
||||
if (!openSslProgressDialog->wasCanceled()
|
||||
|| (exitStatus == QProcess::NormalExit && exitCode != 0)) {
|
||||
|| gitCloner->result() == QtcProcess::FinishedWithError) {
|
||||
failDialog();
|
||||
}
|
||||
});
|
||||
|
@@ -183,7 +183,7 @@ void CMakeProcess::processStandardError()
|
||||
});
|
||||
}
|
||||
|
||||
void CMakeProcess::handleProcessFinished(int code, QProcess::ExitStatus status)
|
||||
void CMakeProcess::handleProcessFinished()
|
||||
{
|
||||
QTC_ASSERT(m_process && m_future, return);
|
||||
|
||||
@@ -192,8 +192,9 @@ void CMakeProcess::handleProcessFinished(int code, QProcess::ExitStatus status)
|
||||
processStandardOutput();
|
||||
processStandardError();
|
||||
|
||||
const int code = m_process->exitCode();
|
||||
QString msg;
|
||||
if (status != QProcess::NormalExit) {
|
||||
if (m_process->exitStatus() != QProcess::NormalExit) {
|
||||
if (m_processWasCanceled) {
|
||||
msg = tr("CMake process was canceled by the user.");
|
||||
} else {
|
||||
|
@@ -64,12 +64,13 @@ public:
|
||||
void processStandardError();
|
||||
|
||||
int lastExitCode() const { return m_lastExitCode; }
|
||||
|
||||
signals:
|
||||
void started();
|
||||
void finished();
|
||||
|
||||
private:
|
||||
void handleProcessFinished(int code, QProcess::ExitStatus status);
|
||||
void handleProcessFinished();
|
||||
void checkForCancelled();
|
||||
|
||||
std::unique_ptr<Utils::QtcProcess> m_process;
|
||||
|
@@ -679,9 +679,9 @@ void ExternalToolRunner::started()
|
||||
m_process->closeWriteChannel();
|
||||
}
|
||||
|
||||
void ExternalToolRunner::finished(int exitCode, QProcess::ExitStatus status)
|
||||
void ExternalToolRunner::finished()
|
||||
{
|
||||
if (status == QProcess::NormalExit && exitCode == 0
|
||||
if (m_process->result() == QtcProcess::FinishedWithSuccess
|
||||
&& (m_tool->outputHandling() == ExternalTool::ReplaceSelection
|
||||
|| m_tool->errorHandling() == ExternalTool::ReplaceSelection)) {
|
||||
ExternalToolManager::emitReplaceSelectionRequested(m_processOutput);
|
||||
|
@@ -135,7 +135,7 @@ public:
|
||||
|
||||
private:
|
||||
void started();
|
||||
void finished(int exitCode, QProcess::ExitStatus status);
|
||||
void finished();
|
||||
void error(QProcess::ProcessError error);
|
||||
void readStandardOutput();
|
||||
void readStandardError();
|
||||
|
@@ -130,11 +130,11 @@ void ExecuteFilter::accept(LocatorFilterEntry selection,
|
||||
p->runHeadCommand();
|
||||
}
|
||||
|
||||
void ExecuteFilter::finished(int exitCode, QProcess::ExitStatus status)
|
||||
void ExecuteFilter::finished()
|
||||
{
|
||||
const QString commandName = headCommand();
|
||||
QString message;
|
||||
if (status == QProcess::NormalExit && exitCode == 0)
|
||||
if (m_process->result() == QtcProcess::FinishedWithSuccess)
|
||||
message = tr("Command \"%1\" finished.").arg(commandName);
|
||||
else
|
||||
message = tr("Command \"%1\" failed.").arg(commandName);
|
||||
|
@@ -55,7 +55,7 @@ public:
|
||||
QString *newText, int *selectionStart, int *selectionLength) const override;
|
||||
|
||||
private:
|
||||
void finished(int exitCode, QProcess::ExitStatus status);
|
||||
void finished();
|
||||
void readStandardOutput();
|
||||
void readStandardError();
|
||||
void runHeadCommand();
|
||||
|
@@ -170,7 +170,7 @@ void CppcheckRunner::handleStarted()
|
||||
m_tool.startParsing();
|
||||
}
|
||||
|
||||
void CppcheckRunner::handleFinished(int)
|
||||
void CppcheckRunner::handleFinished()
|
||||
{
|
||||
if (m_process->error() != QProcess::FailedToStart) {
|
||||
m_tool.finishParsing();
|
||||
|
@@ -61,7 +61,7 @@ private:
|
||||
void readOutput();
|
||||
void readError();
|
||||
void handleStarted();
|
||||
void handleFinished(int);
|
||||
void handleFinished();
|
||||
|
||||
CppcheckTool &m_tool;
|
||||
Utils::QtcProcess *m_process = nullptr;
|
||||
|
@@ -4085,12 +4085,12 @@ void GdbEngine::handleGdbError(QProcess::ProcessError error)
|
||||
}
|
||||
}
|
||||
|
||||
void GdbEngine::handleGdbFinished(int exitCode, QProcess::ExitStatus exitStatus)
|
||||
void GdbEngine::handleGdbFinished()
|
||||
{
|
||||
if (m_commandTimer.isActive())
|
||||
m_commandTimer.stop();
|
||||
|
||||
notifyDebuggerProcessFinished(exitCode, exitStatus, "GDB");
|
||||
notifyDebuggerProcessFinished(m_gdbProc.exitCode(), m_gdbProc.exitStatus(), "GDB");
|
||||
}
|
||||
|
||||
void GdbEngine::abortDebuggerProcess()
|
||||
|
@@ -111,7 +111,7 @@ private: ////////// General Interface //////////
|
||||
// The engine is still running just fine, but it failed to acquire a debuggee.
|
||||
void notifyInferiorSetupFailedHelper(const QString &msg);
|
||||
|
||||
void handleGdbFinished(int exitCode, QProcess::ExitStatus exitStatus);
|
||||
void handleGdbFinished();
|
||||
void handleGdbError(QProcess::ProcessError error);
|
||||
void readGdbStandardOutput();
|
||||
void readGdbStandardError();
|
||||
|
@@ -820,9 +820,9 @@ QString LldbEngine::errorMessage(QProcess::ProcessError error) const
|
||||
}
|
||||
}
|
||||
|
||||
void LldbEngine::handleLldbFinished(int exitCode, QProcess::ExitStatus exitStatus)
|
||||
void LldbEngine::handleLldbFinished()
|
||||
{
|
||||
notifyDebuggerProcessFinished(exitCode, exitStatus, "LLDB");
|
||||
notifyDebuggerProcessFinished(m_lldbProc.exitCode(), m_lldbProc.exitStatus(), "LLDB");
|
||||
}
|
||||
|
||||
void LldbEngine::readLldbStandardError()
|
||||
|
@@ -112,7 +112,7 @@ private:
|
||||
QString errorMessage(QProcess::ProcessError error) const;
|
||||
bool hasCapability(unsigned cap) const override;
|
||||
|
||||
void handleLldbFinished(int exitCode, QProcess::ExitStatus exitStatus);
|
||||
void handleLldbFinished();
|
||||
void handleLldbError(QProcess::ProcessError error);
|
||||
void readLldbStandardOutput();
|
||||
void readLldbStandardError();
|
||||
|
@@ -246,7 +246,7 @@ signals:
|
||||
|
||||
private:
|
||||
void processError(QProcess::ProcessError);
|
||||
void processFinished(int exitCode, QProcess::ExitStatus);
|
||||
void processFinished();
|
||||
void timeout();
|
||||
|
||||
void errorTermination(const QString &msg);
|
||||
@@ -351,16 +351,16 @@ void QueryContext::processError(QProcess::ProcessError e)
|
||||
VcsOutputWindow::appendError(msg);
|
||||
}
|
||||
|
||||
void QueryContext::processFinished(int exitCode, QProcess::ExitStatus es)
|
||||
void QueryContext::processFinished()
|
||||
{
|
||||
if (m_timer.isActive())
|
||||
m_timer.stop();
|
||||
emit errorText(m_error);
|
||||
if (es != QProcess::NormalExit) {
|
||||
if (m_process.exitStatus() != QProcess::NormalExit) {
|
||||
errorTermination(tr("%1 crashed.").arg(m_binary));
|
||||
return;
|
||||
} else if (exitCode) {
|
||||
errorTermination(tr("%1 returned %2.").arg(m_binary).arg(exitCode));
|
||||
} else if (m_process.exitCode()) {
|
||||
errorTermination(tr("%1 returned %2.").arg(m_binary).arg(m_process.exitCode()));
|
||||
return;
|
||||
}
|
||||
emit resultRetrieved(m_output);
|
||||
|
@@ -107,7 +107,7 @@ private:
|
||||
};
|
||||
|
||||
void processError(QProcess::ProcessError);
|
||||
void processFinished(int exitCode, QProcess::ExitStatus);
|
||||
void processFinished();
|
||||
void processReadyReadStandardError();
|
||||
void processReadyReadStandardOutput();
|
||||
|
||||
@@ -176,14 +176,14 @@ void FetchContext::start()
|
||||
m_process.closeWriteChannel();
|
||||
}
|
||||
|
||||
void FetchContext::processFinished(int exitCode, QProcess::ExitStatus es)
|
||||
void FetchContext::processFinished()
|
||||
{
|
||||
if (es != QProcess::NormalExit) {
|
||||
if (m_process.exitStatus() != QProcess::NormalExit) {
|
||||
handleError(tr("%1 crashed.").arg(m_git.toUserOutput()));
|
||||
return;
|
||||
}
|
||||
if (exitCode) {
|
||||
handleError(tr("%1 returned %2.").arg(m_git.toUserOutput()).arg(exitCode));
|
||||
if (m_process.exitCode()) {
|
||||
handleError(tr("%1 returned %2.").arg(m_git.toUserOutput()).arg(m_process.exitCode()));
|
||||
return;
|
||||
}
|
||||
if (m_state == FetchState) {
|
||||
|
@@ -134,10 +134,11 @@ void StdIOClientInterface::sendData(const QByteArray &data)
|
||||
m_process.write(data);
|
||||
}
|
||||
|
||||
void StdIOClientInterface::onProcessFinished(int exitCode, QProcess::ExitStatus exitStatus)
|
||||
void StdIOClientInterface::onProcessFinished()
|
||||
{
|
||||
if (exitStatus == QProcess::CrashExit)
|
||||
emit error(tr("Crashed with exit code %1: %2").arg(exitCode).arg(m_process.errorString()));
|
||||
if (m_process.exitStatus() == QProcess::CrashExit)
|
||||
emit error(tr("Crashed with exit code %1: %2")
|
||||
.arg(m_process.exitCode()).arg(m_process.errorString()));
|
||||
emit finished();
|
||||
}
|
||||
|
||||
|
@@ -89,7 +89,7 @@ protected:
|
||||
private:
|
||||
void readError();
|
||||
void readOutput();
|
||||
void onProcessFinished(int exitCode, QProcess::ExitStatus exitStatus);
|
||||
void onProcessFinished();
|
||||
};
|
||||
|
||||
} // namespace LanguageClient
|
||||
|
@@ -166,7 +166,9 @@ void MesonProcess::setupProcess(const Command &command,
|
||||
if (m_process)
|
||||
disconnect(m_process.get());
|
||||
m_process = std::make_unique<Utils::QtcProcess>();
|
||||
connect(m_process.get(), &QtcProcess::finished, this, &MesonProcess::handleProcessFinished);
|
||||
connect(m_process.get(), &QtcProcess::finished, this, [this] {
|
||||
handleProcessFinished(m_process->exitCode(), m_process->exitStatus());
|
||||
});
|
||||
connect(m_process.get(), &QtcProcess::errorOccurred, this, &MesonProcess::handleProcessError);
|
||||
if (!captureStdo) {
|
||||
connect(m_process.get(),
|
||||
|
@@ -133,19 +133,19 @@ void PerforceChecker::slotError(QProcess::ProcessError error)
|
||||
}
|
||||
}
|
||||
|
||||
void PerforceChecker::slotFinished(int exitCode, QProcess::ExitStatus exitStatus)
|
||||
void PerforceChecker::slotFinished()
|
||||
{
|
||||
if (m_timedOut)
|
||||
return;
|
||||
switch (exitStatus) {
|
||||
switch (m_process.exitStatus()) {
|
||||
case QProcess::CrashExit:
|
||||
emitFailed(tr("\"%1\" crashed.").arg(QDir::toNativeSeparators(m_binary)));
|
||||
break;
|
||||
case QProcess::NormalExit:
|
||||
if (exitCode) {
|
||||
if (m_process.exitCode()) {
|
||||
const QString stdErr = QString::fromLocal8Bit(m_process.readAllStandardError());
|
||||
emitFailed(tr("\"%1\" terminated with exit code %2: %3").
|
||||
arg(QDir::toNativeSeparators(m_binary)).arg(exitCode).arg(stdErr));
|
||||
arg(QDir::toNativeSeparators(m_binary)).arg(m_process.exitCode()).arg(stdErr));
|
||||
} else {
|
||||
parseOutput(QString::fromLocal8Bit(m_process.readAllStandardOutput()));
|
||||
}
|
||||
|
@@ -59,7 +59,7 @@ signals:
|
||||
|
||||
private:
|
||||
void slotError(QProcess::ProcessError error);
|
||||
void slotFinished(int exitCode, QProcess::ExitStatus exitStatus);
|
||||
void slotFinished();
|
||||
void slotTimeOut();
|
||||
|
||||
void emitFailed(const QString &);
|
||||
|
@@ -401,7 +401,7 @@ void AbstractProcessStep::finish(bool success)
|
||||
emit finished(success);
|
||||
}
|
||||
|
||||
void AbstractProcessStep::slotProcessFinished(int, QProcess::ExitStatus)
|
||||
void AbstractProcessStep::slotProcessFinished()
|
||||
{
|
||||
QtcProcess *process = d->m_process.get();
|
||||
if (!process) // Happens when the process was canceled and handed over to the Reaper.
|
||||
|
@@ -76,7 +76,7 @@ protected:
|
||||
private:
|
||||
void processReadyReadStdOutput();
|
||||
void processReadyReadStdError();
|
||||
void slotProcessFinished(int, QProcess::ExitStatus);
|
||||
void slotProcessFinished();
|
||||
|
||||
class Private;
|
||||
Private *d;
|
||||
|
@@ -138,8 +138,9 @@ ApplicationLauncherPrivate::ApplicationLauncherPrivate(ApplicationLauncher *pare
|
||||
this, &ApplicationLauncherPrivate::readLocalStandardOutput);
|
||||
connect(&m_guiProcess, &QtcProcess::errorOccurred,
|
||||
this, &ApplicationLauncherPrivate::localGuiProcessError);
|
||||
connect(&m_guiProcess, &QtcProcess::finished,
|
||||
this, &ApplicationLauncherPrivate::localProcessDone);
|
||||
connect(&m_guiProcess, &QtcProcess::finished, this, [this] {
|
||||
localProcessDone(m_guiProcess.exitCode(), m_guiProcess.exitStatus());
|
||||
});
|
||||
connect(&m_guiProcess, &QtcProcess::started,
|
||||
this, &ApplicationLauncherPrivate::handleProcessStarted);
|
||||
connect(&m_guiProcess, &QtcProcess::errorOccurred,
|
||||
@@ -151,8 +152,9 @@ ApplicationLauncherPrivate::ApplicationLauncherPrivate(ApplicationLauncher *pare
|
||||
this, &ApplicationLauncherPrivate::handleProcessStarted);
|
||||
connect(&m_consoleProcess, &ConsoleProcess::processError,
|
||||
this, &ApplicationLauncherPrivate::localConsoleProcessError);
|
||||
connect(&m_consoleProcess, &ConsoleProcess::processStopped,
|
||||
this, &ApplicationLauncherPrivate::localProcessDone);
|
||||
connect(&m_consoleProcess, &ConsoleProcess::processStopped, this, [this] {
|
||||
localProcessDone(m_consoleProcess.exitCode(), m_consoleProcess.exitStatus());
|
||||
});
|
||||
connect(&m_consoleProcess, &ConsoleProcess::errorOccurred,
|
||||
q, &ApplicationLauncher::error);
|
||||
|
||||
|
@@ -292,15 +292,16 @@ private:
|
||||
.arg(m_killTimer.isActive() ? tr("user") : tr("time out")));
|
||||
}
|
||||
|
||||
void installFinished(int exitCode, QProcess::ExitStatus exitStatus)
|
||||
void installFinished()
|
||||
{
|
||||
m_future.reportFinished();
|
||||
if (exitStatus == QProcess::NormalExit && exitCode == 0) {
|
||||
if (m_process.result() == QtcProcess::FinishedWithSuccess) {
|
||||
if (Client *client = registerLanguageServer(m_python))
|
||||
LanguageClientManager::openDocumentWithClient(m_document, client);
|
||||
} else {
|
||||
Core::MessageManager::writeFlashing(
|
||||
tr("Installing the Python language server failed with exit code %1").arg(exitCode));
|
||||
tr("Installing the Python language server failed with exit code %1")
|
||||
.arg(m_process.exitCode()));
|
||||
}
|
||||
deleteLater();
|
||||
}
|
||||
|
@@ -179,8 +179,10 @@ void WinRtDeviceFactory::onProcessError()
|
||||
tr("Error while executing winrtrunner: %1").arg(m_process->errorString()));
|
||||
}
|
||||
|
||||
void WinRtDeviceFactory::onProcessFinished(int exitCode, QProcess::ExitStatus exitStatus)
|
||||
void WinRtDeviceFactory::onProcessFinished()
|
||||
{
|
||||
int exitCode = m_process->exitCode();
|
||||
QProcess::ExitStatus exitStatus = m_process->exitStatus();
|
||||
qCDebug(winrtDeviceLog) << __FUNCTION__ << "Exit code:" << exitCode <<"\tExit status:"
|
||||
<< exitStatus;
|
||||
if (exitStatus == QProcess::CrashExit) {
|
||||
|
@@ -67,7 +67,7 @@ public:
|
||||
|
||||
private:
|
||||
void onProcessError();
|
||||
void onProcessFinished(int exitCode, QProcess::ExitStatus exitStatus);
|
||||
void onProcessFinished();
|
||||
|
||||
static bool allPrerequisitesLoaded();
|
||||
QString findRunnerFilePath() const;
|
||||
|
@@ -144,13 +144,13 @@ void WinRtRunnerHelper::onProcessReadyReadStdErr()
|
||||
appendMessage(QString::fromLocal8Bit(m_process->readAllStandardError()), Utils::StdErrFormat);
|
||||
}
|
||||
|
||||
void WinRtRunnerHelper::onProcessFinished(int exitCode, QProcess::ExitStatus exitStatus)
|
||||
void WinRtRunnerHelper::onProcessFinished()
|
||||
{
|
||||
QTC_ASSERT(m_process, return);
|
||||
m_process->disconnect();
|
||||
m_process->deleteLater();
|
||||
m_process = nullptr;
|
||||
emit finished(exitCode, exitStatus);
|
||||
emit finished();
|
||||
}
|
||||
|
||||
void WinRtRunnerHelper::onProcessError(QProcess::ProcessError processError)
|
||||
|
@@ -55,7 +55,7 @@ public:
|
||||
|
||||
signals:
|
||||
void started();
|
||||
void finished(int exitCode, QProcess::ExitStatus exitStatus);
|
||||
void finished();
|
||||
void error(QProcess::ProcessError error);
|
||||
|
||||
private:
|
||||
@@ -63,7 +63,7 @@ private:
|
||||
|
||||
void onProcessReadyReadStdOut();
|
||||
void onProcessReadyReadStdErr();
|
||||
void onProcessFinished(int exitCode, QProcess::ExitStatus exitStatus);
|
||||
void onProcessFinished();
|
||||
void onProcessError(QProcess::ProcessError processError);
|
||||
|
||||
void startWinRtRunner(const RunConf &conf);
|
||||
|
Reference in New Issue
Block a user