Valgrind: Inline receiveProcessError()

Change-Id: If866772473032e5f19b0ceeb05a32d40403202f9
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Jarek Kobus
2025-02-19 17:44:04 +01:00
parent cc4bf69d67
commit 277a97a77a
2 changed files with 25 additions and 28 deletions

View File

@@ -31,8 +31,31 @@ ValgrindToolRunner::ValgrindToolRunner(RunControl *runControl)
connect(&m_runner, &ValgrindProcess::appendMessage, this,
[this](const QString &msg, Utils::OutputFormat format) { appendMessage(msg, format); });
connect(&m_runner, &ValgrindProcess::processErrorReceived,
this, &ValgrindToolRunner::receiveProcessError);
connect(&m_runner, &ValgrindProcess::processErrorReceived, this,
[this, runControl](const QString &errorString, Utils::ProcessResult result) {
switch (result) {
case ProcessResult::StartFailed: {
const FilePath valgrind = m_settings.valgrindExecutable();
if (!valgrind.isEmpty()) {
appendMessage(Tr::tr("Error: \"%1\" could not be started: %2")
.arg(valgrind.toUserOutput(), errorString), ErrorMessageFormat);
} else {
appendMessage(Tr::tr("Error: no Valgrind executable set."), ErrorMessageFormat);
}
break;
}
case ProcessResult::Canceled:
appendMessage(Tr::tr("Process terminated."), ErrorMessageFormat);
return; // Intentional.
case ProcessResult::FinishedWithError:
appendMessage(Tr::tr("Process exited with return value %1\n").arg(errorString), NormalMessageFormat);
break;
default:
break;
}
runControl->showOutputPane();
});
connect(&m_runner, &ValgrindProcess::done, this, [this] {
appendMessage(Tr::tr("Analyzing finished."), NormalMessageFormat);
m_progress.reportFinished();
@@ -115,29 +138,4 @@ QStringList ValgrindToolRunner::genericToolArguments() const
return {"--smc-check=" + smcCheckValue};
}
void ValgrindToolRunner::receiveProcessError(const QString &errorString, ProcessResult result)
{
switch (result) {
case ProcessResult::StartFailed: {
const FilePath valgrind = m_settings.valgrindExecutable();
if (!valgrind.isEmpty()) {
appendMessage(Tr::tr("Error: \"%1\" could not be started: %2")
.arg(valgrind.toUserOutput(), errorString), ErrorMessageFormat);
} else {
appendMessage(Tr::tr("Error: no Valgrind executable set."), ErrorMessageFormat);
}
break;
}
case ProcessResult::Canceled:
appendMessage(Tr::tr("Process terminated."), ErrorMessageFormat);
return; // Intentional.
case ProcessResult::FinishedWithError:
appendMessage(Tr::tr("Process exited with return value %1\n").arg(errorString), NormalMessageFormat);
break;
default:
break;
}
runControl()->showOutputPane();
}
} // Valgrid::Internal

View File

@@ -28,7 +28,6 @@ protected:
ValgrindProcess m_runner;
private:
void receiveProcessError(const QString &errorString, Utils::ProcessResult result);
QStringList genericToolArguments() const;
private: