forked from qt-creator/qt-creator
Valgrind: Replace ProcessError with ProcessResult
This one includes the cancellation result, after calling Process::stop(). In this way we get rid of m_isStopping field. Change-Id: If29289dc6da88855951e2bb1cfebe82a2aa33cbf Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -92,7 +92,6 @@ void ValgrindToolRunner::start()
|
||||
|
||||
void ValgrindToolRunner::stop()
|
||||
{
|
||||
m_isStopping = true;
|
||||
m_runner.stop();
|
||||
appendMessage(Tr::tr("Terminating process..."), ErrorMessageFormat);
|
||||
}
|
||||
@@ -119,24 +118,28 @@ QStringList ValgrindToolRunner::genericToolArguments() const
|
||||
return {"--smc-check=" + smcCheckValue};
|
||||
}
|
||||
|
||||
void ValgrindToolRunner::receiveProcessError(const QString &message, QProcess::ProcessError error)
|
||||
void ValgrindToolRunner::receiveProcessError(const QString &errorString, ProcessResult result)
|
||||
{
|
||||
if (error == QProcess::FailedToStart) {
|
||||
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(), message), ErrorMessageFormat);
|
||||
.arg(valgrind.toUserOutput(), errorString), ErrorMessageFormat);
|
||||
} else {
|
||||
appendMessage(Tr::tr("Error: no Valgrind executable set."), ErrorMessageFormat);
|
||||
}
|
||||
} else if (m_isStopping && error == QProcess::Crashed) { // process gets killed on stop
|
||||
appendMessage(Tr::tr("Process terminated."), ErrorMessageFormat);
|
||||
} else {
|
||||
appendMessage(Tr::tr("Process exited with return value %1\n").arg(message), NormalMessageFormat);
|
||||
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;
|
||||
}
|
||||
|
||||
if (m_isStopping)
|
||||
return;
|
||||
|
||||
QObject *obj = ExtensionSystem::PluginManager::getObjectByName("AppOutputPane");
|
||||
if (auto pane = qobject_cast<IOutputPane *>(obj))
|
||||
|
@@ -28,12 +28,10 @@ protected:
|
||||
ValgrindProcess m_runner;
|
||||
|
||||
private:
|
||||
void receiveProcessError(const QString &message, QProcess::ProcessError error);
|
||||
|
||||
void receiveProcessError(const QString &errorString, Utils::ProcessResult result);
|
||||
QStringList genericToolArguments() const;
|
||||
|
||||
private:
|
||||
bool m_isStopping = false;
|
||||
QString m_progressTitle;
|
||||
QFutureInterface<void> m_progress;
|
||||
};
|
||||
|
@@ -125,7 +125,7 @@ public:
|
||||
connect(runner, &ValgrindProcess::logMessageReceived, this, [](const QByteArray &log) {
|
||||
qDebug() << "log message received:" << log;
|
||||
});
|
||||
connect(runner, &ValgrindProcess::processErrorReceived, this, [this](const QString &) {
|
||||
connect(runner, &ValgrindProcess::processErrorReceived, this, [this] {
|
||||
m_errorReceived = true;
|
||||
});
|
||||
}
|
||||
|
@@ -120,7 +120,7 @@ Group ValgrindProcessPrivate::runRecipe() const
|
||||
});
|
||||
if (!xmlServer->listen(m_localServerAddress)) {
|
||||
emit q->processErrorReceived(Tr::tr("XmlServer on %1:").arg(ip) + ' '
|
||||
+ xmlServer->errorString(), QProcess::FailedToStart);
|
||||
+ xmlServer->errorString(), ProcessResult::StartFailed);
|
||||
return false;
|
||||
}
|
||||
xmlServer->setMaxPendingConnections(1);
|
||||
@@ -137,7 +137,7 @@ Group ValgrindProcessPrivate::runRecipe() const
|
||||
});
|
||||
if (!logServer->listen(m_localServerAddress)) {
|
||||
emit q->processErrorReceived(Tr::tr("LogServer on %1:").arg(ip) + ' '
|
||||
+ logServer->errorString(), QProcess::FailedToStart);
|
||||
+ logServer->errorString(), ProcessResult::StartFailed);
|
||||
return false;
|
||||
}
|
||||
logServer->setMaxPendingConnections(1);
|
||||
@@ -183,7 +183,7 @@ Group ValgrindProcessPrivate::runRecipe() const
|
||||
connect(this, &ValgrindProcessPrivate::stopRequested, processPtr, &Process::stop);
|
||||
};
|
||||
const auto onProcessDone = [this, storage](const Process &process) {
|
||||
emit q->processErrorReceived(process.errorString(), process.error());
|
||||
emit q->processErrorReceived(process.errorString(), process.result());
|
||||
};
|
||||
|
||||
const auto isAddressValid = [this] { return !m_localServerAddress.isNull(); };
|
||||
|
@@ -6,6 +6,7 @@
|
||||
#include <solutions/tasking/tasktree.h>
|
||||
|
||||
#include <utils/outputformat.h>
|
||||
#include <utils/processenums.h>
|
||||
|
||||
#include <QProcess>
|
||||
|
||||
@@ -48,7 +49,7 @@ public:
|
||||
signals:
|
||||
void appendMessage(const QString &, Utils::OutputFormat);
|
||||
void logMessageReceived(const QByteArray &);
|
||||
void processErrorReceived(const QString &, QProcess::ProcessError);
|
||||
void processErrorReceived(const QString &errorString, Utils::ProcessResult result);
|
||||
void valgrindStarted(qint64 pid);
|
||||
void done(Tasking::DoneResult result);
|
||||
|
||||
|
@@ -106,12 +106,12 @@ void ValgrindTestRunnerTest::logMessageReceived(const QByteArray &message)
|
||||
m_logMessages << message;
|
||||
}
|
||||
|
||||
void ValgrindTestRunnerTest::internalError(const QString &error)
|
||||
void ValgrindTestRunnerTest::internalError(const QString &errorString)
|
||||
{
|
||||
if (!m_expectCrash)
|
||||
QFAIL(qPrintable(error));
|
||||
QFAIL(qPrintable(errorString));
|
||||
else
|
||||
qDebug() << "expected crash:" << error;
|
||||
qDebug() << "expected crash:" << errorString;
|
||||
}
|
||||
|
||||
void ValgrindTestRunnerTest::error(const Error &error)
|
||||
|
Reference in New Issue
Block a user