Utils: Remove SynchronousProcess::stopProcess

Handled by QtcProcess::stopProcess nowadays.

Change-Id: I5acf7db470f9b75989edc18e48c9a48e01b50868
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
hjk
2021-05-04 07:38:23 +02:00
parent ef21aacf1f
commit 9995b82612
3 changed files with 10 additions and 29 deletions

View File

@@ -550,7 +550,7 @@ SynchronousProcessResponse SynchronousProcess::runBlocking(const CommandLine &cm
bool SynchronousProcess::terminate() bool SynchronousProcess::terminate()
{ {
return stopProcess(d->m_process); return d->m_process.stopProcess();
} }
static inline bool askToKill(const QString &binary = QString()) static inline bool askToKill(const QString &binary = QString())
@@ -582,7 +582,7 @@ void SynchronousProcess::slotTimeout()
const bool terminate = !d->m_timeOutMessageBoxEnabled || askToKill(d->m_binary.toString()); const bool terminate = !d->m_timeOutMessageBoxEnabled || askToKill(d->m_binary.toString());
d->m_waitingForUser = false; d->m_waitingForUser = false;
if (terminate) { if (terminate) {
SynchronousProcess::stopProcess(d->m_process); d->m_process.stopProcess();
d->m_result.result = SynchronousProcessResponse::Hang; d->m_result.result = SynchronousProcessResponse::Hang;
} else { } else {
d->m_hangTimerCount = 0; d->m_hangTimerCount = 0;
@@ -689,17 +689,6 @@ bool SynchronousProcess::readDataFromProcess(QProcess &p, int timeoutS,
return finished; return finished;
} }
bool SynchronousProcess::stopProcess(QProcess &p)
{
if (p.state() == QProcess::NotRunning)
return true;
p.terminate();
if (p.waitForFinished(300))
return true;
p.kill();
return p.waitForFinished(300);
}
// Path utilities // Path utilities
// Locate a binary in a directory, applying all kinds of // Locate a binary in a directory, applying all kinds of

View File

@@ -142,9 +142,6 @@ public:
QByteArray *rawStdOut = nullptr, QByteArray *rawStdOut = nullptr,
QByteArray *rawStdErr = nullptr, QByteArray *rawStdErr = nullptr,
bool timeOutMessageBox = false); bool timeOutMessageBox = false);
// Stop a process by first calling terminate() (allowing for signal handling) and
// then kill().
static bool stopProcess(QProcess &p);
// Helpers to find binaries. Do not use it for other path variables // Helpers to find binaries. Do not use it for other path variables
// and file types. // and file types.

View File

@@ -29,10 +29,11 @@
#include "watchutils.h" #include "watchutils.h"
#include <utils/fileutils.h> #include <utils/fileutils.h>
#ifdef Q_OS_WIN
#include <utils/environment.h> #include <utils/environment.h>
#ifdef Q_CC_MSVC
#include <utils/qtcprocess.h> #include <utils/qtcprocess.h>
#ifdef Q_OS_WIN
#ifdef Q_CC_MSVC
#include <utils/synchronousprocess.h> #include <utils/synchronousprocess.h>
#endif // Q_CC_MSVC #endif // Q_CC_MSVC
#endif // Q_OS_WIN #endif // Q_OS_WIN
@@ -40,6 +41,10 @@
#include <QtTest> #include <QtTest>
#include <math.h> #include <math.h>
#ifndef CDBEXT_PATH
#define CDBEXT_PATH ""
#endif
#define MSKIP_SINGLE(x) do { disarm(); QSKIP(x); } while (0) #define MSKIP_SINGLE(x) do { disarm(); QSKIP(x); } while (0)
using namespace Debugger; using namespace Debugger;
@@ -61,8 +66,6 @@ enum class Language
Fortran90 Fortran90
}; };
#ifdef Q_CC_MSVC
// Copied from msvctoolchain.cpp to avoid plugin dependency. // Copied from msvctoolchain.cpp to avoid plugin dependency.
static bool generateEnvironmentSettings(Utils::Environment &env, static bool generateEnvironmentSettings(Utils::Environment &env,
const QString &batchFile, const QString &batchFile,
@@ -120,7 +123,7 @@ static bool generateEnvironmentSettings(Utils::Environment &env,
} }
if (!run.waitForFinished()) { if (!run.waitForFinished()) {
qWarning("%s: Timeout running '%s'", Q_FUNC_INFO, qPrintable(batchFile)); qWarning("%s: Timeout running '%s'", Q_FUNC_INFO, qPrintable(batchFile));
Utils::SynchronousProcess::stopProcess(run); run.stopProcess();
return false; return false;
} }
// The SDK/MSVC scripts do not return exit codes != 0. Check on stdout. // The SDK/MSVC scripts do not return exit codes != 0. Check on stdout.
@@ -155,12 +158,6 @@ static bool generateEnvironmentSettings(Utils::Environment &env,
} }
#ifndef CDBEXT_PATH
#define CDBEXT_PATH ""
#endif
#endif // Q_CC_MSVC
struct VersionBase struct VersionBase
{ {
// Minimum and maximum are inclusive. // Minimum and maximum are inclusive.
@@ -1245,7 +1242,6 @@ void tst_Dumpers::initTestCase()
qDebug() << "Make path : " << m_makeBinary; qDebug() << "Make path : " << m_makeBinary;
qDebug() << "Gdb version : " << m_debuggerVersion; qDebug() << "Gdb version : " << m_debuggerVersion;
} else if (m_debuggerEngine == CdbEngine) { } else if (m_debuggerEngine == CdbEngine) {
#ifdef Q_CC_MSVC
QByteArray envBat = qgetenv("QTC_MSVC_ENV_BAT"); QByteArray envBat = qgetenv("QTC_MSVC_ENV_BAT");
QMap <QString, QString> envPairs; QMap <QString, QString> envPairs;
Utils::Environment env = Utils::Environment::systemEnvironment(); Utils::Environment env = Utils::Environment::systemEnvironment();
@@ -1273,7 +1269,6 @@ void tst_Dumpers::initTestCase()
QRegularExpressionMatch match = reg.match(output); QRegularExpressionMatch match = reg.match(output);
if (match.matchType() != QRegularExpression::NoMatch) if (match.matchType() != QRegularExpression::NoMatch)
m_msvcVersion = QString(match.captured(1) + match.captured(2)).toInt(); m_msvcVersion = QString(match.captured(1) + match.captured(2)).toInt();
#endif //Q_CC_MSVC
} else if (m_debuggerEngine == LldbEngine) { } else if (m_debuggerEngine == LldbEngine) {
qDebug() << "Dumper dir : " << DUMPERDIR; qDebug() << "Dumper dir : " << DUMPERDIR;
QProcess debugger; QProcess debugger;