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