Fix up QProcess::waitForFinished()

waitForFinish returns false if the process is no longer running at
the time of the call. Handle that throughout the codebase.

Change-Id: Ia7194095454e82efbd4eb88f2d55926bdd09e094
Reviewed-by: hjk <hjk@theqtcompany.com>
This commit is contained in:
Tobias Hunger
2016-04-29 16:52:58 +02:00
parent 1a248b1b93
commit ddefe062c7
38 changed files with 374 additions and 489 deletions

View File

@@ -25,6 +25,8 @@
#include "iosprobe.h"
#include <utils/synchronousprocess.h>
#include <QDir>
#include <QFileInfo>
#include <QFileInfoList>
@@ -93,14 +95,16 @@ void IosProbe::addDeveloperPath(const QString &path)
void IosProbe::detectDeveloperPaths()
{
QProcess selectedXcode;
QString program = QLatin1String("/usr/bin/xcode-select");
QStringList arguments(QLatin1String("--print-path"));
selectedXcode.start(program, arguments, QProcess::ReadOnly);
if (!selectedXcode.waitForFinished() || selectedXcode.exitCode()) {
Utils::SynchronousProcess selectedXcode;
selectedXcode.setTimeoutS(5);
Utils::SynchronousProcessResponse response = selectedXcode.run(program, arguments);
if (response.result != Utils::SynchronousProcessResponse::Finished) {
qCWarning(probeLog) << QString::fromLatin1("Could not detect selected xcode with /usr/bin/xcode-select");
} else {
QString path = QString::fromLocal8Bit(selectedXcode.readAllStandardOutput());
QString path = response.stdOut;
path.chop(1);
addDeveloperPath(path);
}

View File

@@ -187,7 +187,7 @@ Utils::Port IosSimulator::nextPort() const
if (!portVerifier.waitForStarted())
break;
portVerifier.closeWriteChannel();
if (!portVerifier.waitForFinished())
if (!portVerifier.waitForFinished() && portVerifier.state() == QProcess::Running)
break;
if (portVerifier.exitStatus() != QProcess::NormalExit
|| portVerifier.exitCode() != 0)