iOS: Fix run without deploy on iOS simulator

Task-number: QTCREATORBUG-18107
Change-Id: Ie847cdab672ff2df7af0c2fee742901de0783861
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
Vikas Pachdha
2017-04-28 08:27:10 +02:00
parent f2e296f7c7
commit a4a78ae8b1
3 changed files with 43 additions and 7 deletions

View File

@@ -398,7 +398,29 @@ void SimulatorControlPrivate::startSimulator(QFutureInterface<SimulatorControl::
{
SimulatorControl::ResponseData response(simUdid);
SimulatorInfo simInfo = deviceInfo(simUdid);
if (simInfo.available && simInfo.isShutdown()) {
if (!simInfo.available) {
qCDebug(simulatorLog) << "Simulator device is not available." << simUdid;
return;
}
// Shutting down state checks are for the case when simulator start is called within a short
// interval of closing the previous interval of the simulator. We wait untill the shutdown
// process is complete.
auto start = chrono::high_resolution_clock::now();
while (simInfo.isShuttingDown() && !checkForTimeout(start, SIMULATOR_START_TIMEOUT)) {
// Wait till the simulator shuts down, if doing so.
QThread::currentThread()->msleep(100);
simInfo = deviceInfo(simUdid);
}
if (simInfo.isShuttingDown()) {
qCDebug(simulatorLog) << "Can not start Simulator device. "
<< "Previous instance taking too long to shutdown." << simInfo;
return;
}
if (simInfo.isShutdown()) {
const QString cmd = IosConfigurations::developerPath()
.appendPath(QStringLiteral("/Applications/Simulator.app/Contents/MacOS/Simulator"))
.toString();
@@ -410,7 +432,7 @@ void SimulatorControlPrivate::startSimulator(QFutureInterface<SimulatorControl::
// At this point the sim device exists, available and was not running.
// So the simulator is started and we'll wait for it to reach to a state
// where we can interact with it.
auto start = chrono::high_resolution_clock::now();
start = chrono::high_resolution_clock::now();
SimulatorInfo info;
do {
info = deviceInfo(simUdid);
@@ -424,6 +446,9 @@ void SimulatorControlPrivate::startSimulator(QFutureInterface<SimulatorControl::
} else {
qCDebug(simulatorLog) << "Error starting simulator.";
}
} else {
qCDebug(simulatorLog) << "Can not start Simulator device. Simulator not in shutdown state."
<< simInfo;
}
if (!fi.isCanceled()) {
@@ -541,5 +566,13 @@ void SimulatorControlPrivate::takeSceenshot(QFutureInterface<SimulatorControl::R
fi.reportResult(response);
}
QDebug &operator<<(QDebug &stream, const SimulatorInfo &info)
{
stream << "Name: " << info.name << "UDID: " << info.identifier
<< "Availability: " << info.available << "State: " << info.state
<< "Runtime: " << info.runtimeName;
return stream;
}
} // namespace Internal
} // namespace Ios