forked from qt-creator/qt-creator
Replace QtcProcess::stopProcess() by stop() plus waitForFinished
... or nothing, if the process object is destroyed immediately. Change-Id: I6a1e1928bc49fc20a1c0e0ee9b8f4f723276bbca Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
@@ -368,7 +368,10 @@ void ShellCommand::runFullySynchronous(QtcProcess &process, const FilePath &work
|
|||||||
|
|
||||||
void ShellCommand::runSynchronous(QtcProcess &process, const FilePath &workingDirectory)
|
void ShellCommand::runSynchronous(QtcProcess &process, const FilePath &workingDirectory)
|
||||||
{
|
{
|
||||||
connect(this, &ShellCommand::terminate, &process, &QtcProcess::stopProcess);
|
connect(this, &ShellCommand::terminate, &process, [&process] {
|
||||||
|
process.stop();
|
||||||
|
process.waitForFinished();
|
||||||
|
});
|
||||||
process.setEnvironment(processEnvironment());
|
process.setEnvironment(processEnvironment());
|
||||||
if (d->m_codec)
|
if (d->m_codec)
|
||||||
process.setCodec(d->m_codec);
|
process.setCodec(d->m_codec);
|
||||||
|
@@ -363,7 +363,8 @@ FilePath AndroidQmlPreviewWorker::createQmlrcFile(const FilePath &workFolder,
|
|||||||
QByteArray stdOut;
|
QByteArray stdOut;
|
||||||
QByteArray stdErr;
|
QByteArray stdErr;
|
||||||
if (!rccProcess.readDataFromProcess(30, &stdOut, &stdErr, true)) {
|
if (!rccProcess.readDataFromProcess(30, &stdOut, &stdErr, true)) {
|
||||||
rccProcess.stopProcess();
|
rccProcess.stop();
|
||||||
|
rccProcess.waitForFinished();
|
||||||
appendMessage(tr("A timeout occurred running \"%1\"").
|
appendMessage(tr("A timeout occurred running \"%1\"").
|
||||||
arg(rccProcess.commandLine().toUserOutput()), StdErrFormat);
|
arg(rccProcess.commandLine().toUserOutput()), StdErrFormat);
|
||||||
qrcPath.removeFile();
|
qrcPath.removeFile();
|
||||||
|
@@ -166,8 +166,10 @@ static void sdkManagerCommand(const AndroidConfig &config, const QStringList &ar
|
|||||||
proc.setTimeoutS(timeout);
|
proc.setTimeoutS(timeout);
|
||||||
proc.setStdOutCallback([offset, progressQuota, &proc, &assertionFound, &fi](const QString &out) {
|
proc.setStdOutCallback([offset, progressQuota, &proc, &assertionFound, &fi](const QString &out) {
|
||||||
int progressPercent = parseProgress(out, assertionFound);
|
int progressPercent = parseProgress(out, assertionFound);
|
||||||
if (assertionFound)
|
if (assertionFound) {
|
||||||
proc.stopProcess();
|
proc.stop();
|
||||||
|
proc.waitForFinished();
|
||||||
|
}
|
||||||
if (progressPercent != -1)
|
if (progressPercent != -1)
|
||||||
fi.setProgressValue(offset + qRound((progressPercent / 100.0) * progressQuota));
|
fi.setProgressValue(offset + qRound((progressPercent / 100.0) * progressQuota));
|
||||||
});
|
});
|
||||||
@@ -175,8 +177,10 @@ static void sdkManagerCommand(const AndroidConfig &config, const QStringList &ar
|
|||||||
output.stdError = err;
|
output.stdError = err;
|
||||||
});
|
});
|
||||||
if (interruptible) {
|
if (interruptible) {
|
||||||
QObject::connect(&sdkManager, &AndroidSdkManager::cancelActiveOperations,
|
QObject::connect(&sdkManager, &AndroidSdkManager::cancelActiveOperations, &proc, [&proc] {
|
||||||
&proc, &QtcProcess::stopProcess);
|
proc.stop();
|
||||||
|
proc.waitForFinished();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
proc.setCommand({config.sdkManagerToolPath(), newArgs});
|
proc.setCommand({config.sdkManagerToolPath(), newArgs});
|
||||||
proc.runBlocking(EventLoopMode::On);
|
proc.runBlocking(EventLoopMode::On);
|
||||||
|
@@ -71,7 +71,8 @@ ClangToolRunner::~ClangToolRunner()
|
|||||||
m_process->kill();
|
m_process->kill();
|
||||||
m_process->waitForFinished(100);
|
m_process->waitForFinished(100);
|
||||||
} else {
|
} else {
|
||||||
m_process->stopProcess();
|
m_process->stop();
|
||||||
|
m_process->waitForFinished();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -112,7 +112,8 @@ static bool runPatchHelper(const QByteArray &input, const FilePath &workingDirec
|
|||||||
QByteArray stdOut;
|
QByteArray stdOut;
|
||||||
QByteArray stdErr;
|
QByteArray stdErr;
|
||||||
if (!patchProcess.readDataFromProcess(30, &stdOut, &stdErr, true)) {
|
if (!patchProcess.readDataFromProcess(30, &stdOut, &stdErr, true)) {
|
||||||
patchProcess.stopProcess();
|
patchProcess.stop();
|
||||||
|
patchProcess.waitForFinished();
|
||||||
MessageManager::writeFlashing(
|
MessageManager::writeFlashing(
|
||||||
QApplication::translate("Core::PatchTool", "A timeout occurred running \"%1\"")
|
QApplication::translate("Core::PatchTool", "A timeout occurred running \"%1\"")
|
||||||
.arg(patch.toUserOutput()));
|
.arg(patch.toUserOutput()));
|
||||||
|
@@ -335,7 +335,8 @@ void QueryContext::errorTermination(const QString &msg)
|
|||||||
|
|
||||||
void QueryContext::terminate()
|
void QueryContext::terminate()
|
||||||
{
|
{
|
||||||
m_process.stopProcess();
|
m_process.stop();
|
||||||
|
m_process.waitForFinished();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QueryContext::processDone()
|
void QueryContext::processDone()
|
||||||
|
@@ -259,7 +259,8 @@ void FetchContext::checkout()
|
|||||||
|
|
||||||
void FetchContext::terminate()
|
void FetchContext::terminate()
|
||||||
{
|
{
|
||||||
m_process.stopProcess();
|
m_process.stop();
|
||||||
|
m_process.waitForFinished();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -137,7 +137,8 @@ void QueryRunner::start()
|
|||||||
|
|
||||||
void QueryRunner::terminate()
|
void QueryRunner::terminate()
|
||||||
{
|
{
|
||||||
m_process.stopProcess();
|
m_process.stop();
|
||||||
|
m_process.waitForFinished();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QueryRunner::errorTermination(const QString &msg)
|
void QueryRunner::errorTermination(const QString &msg)
|
||||||
|
@@ -105,15 +105,13 @@ StdIOClientInterface::StdIOClientInterface()
|
|||||||
|
|
||||||
StdIOClientInterface::~StdIOClientInterface()
|
StdIOClientInterface::~StdIOClientInterface()
|
||||||
{
|
{
|
||||||
if (m_process)
|
|
||||||
m_process->stopProcess();
|
|
||||||
delete m_process;
|
delete m_process;
|
||||||
}
|
}
|
||||||
|
|
||||||
void StdIOClientInterface::startImpl()
|
void StdIOClientInterface::startImpl()
|
||||||
{
|
{
|
||||||
if (m_process) {
|
if (m_process) {
|
||||||
QTC_ASSERT(!m_process->isRunning(), m_process->stopProcess() );
|
QTC_CHECK(!m_process->isRunning());
|
||||||
delete m_process;
|
delete m_process;
|
||||||
}
|
}
|
||||||
m_process = new Utils::QtcProcess;
|
m_process = new Utils::QtcProcess;
|
||||||
|
@@ -107,7 +107,8 @@ void PerforceChecker::slotTimeOut()
|
|||||||
if (!isRunning())
|
if (!isRunning())
|
||||||
return;
|
return;
|
||||||
m_timedOut = true;
|
m_timedOut = true;
|
||||||
m_process.stopProcess();
|
m_process.stop();
|
||||||
|
m_process.waitForFinished();
|
||||||
emitFailed(tr("\"%1\" timed out after %2 ms.").arg(m_binary.toUserOutput()).arg(m_timeOutMS));
|
emitFailed(tr("\"%1\" timed out after %2 ms.").arg(m_binary.toUserOutput()).arg(m_timeOutMS));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1329,7 +1329,8 @@ PerforceResponse PerforcePluginPrivate::fullySynchronousProcess(const FilePath &
|
|||||||
QByteArray stdErr;
|
QByteArray stdErr;
|
||||||
const int timeOutS = (flags & LongTimeOut) ? m_settings.longTimeOutS() : m_settings.timeOutS.value();
|
const int timeOutS = (flags & LongTimeOut) ? m_settings.longTimeOutS() : m_settings.timeOutS.value();
|
||||||
if (!process.readDataFromProcess(timeOutS, &stdOut, &stdErr, true)) {
|
if (!process.readDataFromProcess(timeOutS, &stdOut, &stdErr, true)) {
|
||||||
process.stopProcess();
|
process.stop();
|
||||||
|
process.waitForFinished();
|
||||||
response.error = true;
|
response.error = true;
|
||||||
response.message = msgTimeout(timeOutS);
|
response.message = msgTimeout(timeOutS);
|
||||||
return response;
|
return response;
|
||||||
|
@@ -1336,7 +1336,8 @@ void SimpleTargetRunnerPrivate::stop()
|
|||||||
if (m_isLocal) {
|
if (m_isLocal) {
|
||||||
if (!isRunning())
|
if (!isRunning())
|
||||||
return;
|
return;
|
||||||
m_process.stopProcess();
|
m_process.stop();
|
||||||
|
m_process.waitForFinished();
|
||||||
QTimer::singleShot(100, this, [this] { forwardDone(); });
|
QTimer::singleShot(100, this, [this] { forwardDone(); });
|
||||||
} else {
|
} else {
|
||||||
if (m_stopRequested)
|
if (m_stopRequested)
|
||||||
|
@@ -95,7 +95,8 @@ void PipInstallTask::run()
|
|||||||
|
|
||||||
void PipInstallTask::cancel()
|
void PipInstallTask::cancel()
|
||||||
{
|
{
|
||||||
m_process.stopProcess();
|
m_process.stop();
|
||||||
|
m_process.waitForFinished();
|
||||||
Core::MessageManager::writeFlashing(
|
Core::MessageManager::writeFlashing(
|
||||||
tr("The %1 installation was canceled by %2.")
|
tr("The %1 installation was canceled by %2.")
|
||||||
.arg(m_package.displayName, m_killTimer.isActive() ? tr("user") : tr("time out")));
|
.arg(m_package.displayName, m_killTimer.isActive() ? tr("user") : tr("time out")));
|
||||||
|
@@ -255,7 +255,6 @@ void GenerateResource::generateMenuEntry()
|
|||||||
QByteArray stdOut;
|
QByteArray stdOut;
|
||||||
QByteArray stdErr;
|
QByteArray stdErr;
|
||||||
if (!rccProcess.readDataFromProcess(30, &stdOut, &stdErr, true)) {
|
if (!rccProcess.readDataFromProcess(30, &stdOut, &stdErr, true)) {
|
||||||
rccProcess.stopProcess();
|
|
||||||
Core::MessageManager::writeDisrupting(
|
Core::MessageManager::writeDisrupting(
|
||||||
QCoreApplication::translate("QmlDesigner::GenerateResource",
|
QCoreApplication::translate("QmlDesigner::GenerateResource",
|
||||||
"A timeout occurred running \"%1\"")
|
"A timeout occurred running \"%1\"")
|
||||||
@@ -415,7 +414,6 @@ void GenerateResource::generateMenuEntry()
|
|||||||
QByteArray stdOut;
|
QByteArray stdOut;
|
||||||
QByteArray stdErr;
|
QByteArray stdErr;
|
||||||
if (!rccProcess.readDataFromProcess(30, &stdOut, &stdErr, true)) {
|
if (!rccProcess.readDataFromProcess(30, &stdOut, &stdErr, true)) {
|
||||||
rccProcess.stopProcess();
|
|
||||||
Core::MessageManager::writeDisrupting(
|
Core::MessageManager::writeDisrupting(
|
||||||
QCoreApplication::translate("QmlDesigner::GenerateResource",
|
QCoreApplication::translate("QmlDesigner::GenerateResource",
|
||||||
"A timeout occurred running \"%1\"")
|
"A timeout occurred running \"%1\"")
|
||||||
@@ -545,7 +543,6 @@ void GenerateResource::generateMenuEntry()
|
|||||||
QByteArray stdOut;
|
QByteArray stdOut;
|
||||||
QByteArray stdErr;
|
QByteArray stdErr;
|
||||||
if (!rccProcess.readDataFromProcess(30, &stdOut, &stdErr, true)) {
|
if (!rccProcess.readDataFromProcess(30, &stdOut, &stdErr, true)) {
|
||||||
rccProcess.stopProcess();
|
|
||||||
Core::MessageManager::writeDisrupting(
|
Core::MessageManager::writeDisrupting(
|
||||||
QCoreApplication::translate("QmlDesigner::GenerateResource",
|
QCoreApplication::translate("QmlDesigner::GenerateResource",
|
||||||
"A timeout occurred running \"%1\"")
|
"A timeout occurred running \"%1\"")
|
||||||
|
@@ -118,10 +118,8 @@ EnvironmentItems QnxUtils::qnxEnvironmentFromEnvFile(const FilePath &filePath)
|
|||||||
QApplication::setOverrideCursor(Qt::BusyCursor);
|
QApplication::setOverrideCursor(Qt::BusyCursor);
|
||||||
bool waitResult = process.waitForFinished(10000);
|
bool waitResult = process.waitForFinished(10000);
|
||||||
QApplication::restoreOverrideCursor();
|
QApplication::restoreOverrideCursor();
|
||||||
if (!waitResult) {
|
if (!waitResult)
|
||||||
process.stopProcess();
|
|
||||||
return items;
|
return items;
|
||||||
}
|
|
||||||
|
|
||||||
if (process.result() != ProcessResult::FinishedWithSuccess)
|
if (process.result() != ProcessResult::FinishedWithSuccess)
|
||||||
return items;
|
return items;
|
||||||
|
@@ -1809,7 +1809,6 @@ static QByteArray runQmakeQuery(const FilePath &binary, const Environment &env,
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
if (!process.waitForFinished(timeOutMS)) {
|
if (!process.waitForFinished(timeOutMS)) {
|
||||||
process.stopProcess();
|
|
||||||
*error = QCoreApplication::translate("QtVersion", "Timeout running \"%1\" (%2 ms).")
|
*error = QCoreApplication::translate("QtVersion", "Timeout running \"%1\" (%2 ms).")
|
||||||
.arg(binary.displayName()).arg(timeOutMS);
|
.arg(binary.displayName()).arg(timeOutMS);
|
||||||
return {};
|
return {};
|
||||||
|
@@ -669,7 +669,6 @@ bool VcsBaseSubmitEditor::runSubmitMessageCheckScript(const QString &checkScript
|
|||||||
QByteArray stdOutData;
|
QByteArray stdOutData;
|
||||||
QByteArray stdErrData;
|
QByteArray stdErrData;
|
||||||
if (!checkProcess.readDataFromProcess(30, &stdOutData, &stdErrData, false)) {
|
if (!checkProcess.readDataFromProcess(30, &stdOutData, &stdErrData, false)) {
|
||||||
checkProcess.stopProcess();
|
|
||||||
*errorMessage = tr("The check script \"%1\" timed out.").
|
*errorMessage = tr("The check script \"%1\" timed out.").
|
||||||
arg(QDir::toNativeSeparators(checkScript));
|
arg(QDir::toNativeSeparators(checkScript));
|
||||||
return false;
|
return false;
|
||||||
|
Reference in New Issue
Block a user