forked from qt-creator/qt-creator
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:
@@ -848,13 +848,12 @@ void IosSimulatorToolHandlerPrivate::requestRunApp(const QString &appBundlePath,
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto onSimulatorStart = [this, extraArgs] (const SimulatorControl::ResponseData &response) {
|
auto onSimulatorStart = [this, extraArgs] (const SimulatorControl::ResponseData &response) {
|
||||||
if (isResponseValid(response))
|
if (!isResponseValid(response))
|
||||||
return;
|
return;
|
||||||
if (response.success) {
|
if (response.success) {
|
||||||
launchAppOnSimulator(extraArgs);
|
launchAppOnSimulator(extraArgs);
|
||||||
} else {
|
} else {
|
||||||
errorMsg(IosToolHandler::tr("Application launch on Simulator failed. Simulator not running.")
|
errorMsg(IosToolHandler::tr("Application launch on Simulator failed. Simulator not running."));
|
||||||
.arg(bundlePath));
|
|
||||||
didStartApp(bundlePath, deviceId, Ios::IosToolHandler::Failure);
|
didStartApp(bundlePath, deviceId, Ios::IosToolHandler::Failure);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -398,7 +398,29 @@ void SimulatorControlPrivate::startSimulator(QFutureInterface<SimulatorControl::
|
|||||||
{
|
{
|
||||||
SimulatorControl::ResponseData response(simUdid);
|
SimulatorControl::ResponseData response(simUdid);
|
||||||
SimulatorInfo simInfo = deviceInfo(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()
|
const QString cmd = IosConfigurations::developerPath()
|
||||||
.appendPath(QStringLiteral("/Applications/Simulator.app/Contents/MacOS/Simulator"))
|
.appendPath(QStringLiteral("/Applications/Simulator.app/Contents/MacOS/Simulator"))
|
||||||
.toString();
|
.toString();
|
||||||
@@ -410,7 +432,7 @@ void SimulatorControlPrivate::startSimulator(QFutureInterface<SimulatorControl::
|
|||||||
// At this point the sim device exists, available and was not running.
|
// 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
|
// So the simulator is started and we'll wait for it to reach to a state
|
||||||
// where we can interact with it.
|
// where we can interact with it.
|
||||||
auto start = chrono::high_resolution_clock::now();
|
start = chrono::high_resolution_clock::now();
|
||||||
SimulatorInfo info;
|
SimulatorInfo info;
|
||||||
do {
|
do {
|
||||||
info = deviceInfo(simUdid);
|
info = deviceInfo(simUdid);
|
||||||
@@ -424,6 +446,9 @@ void SimulatorControlPrivate::startSimulator(QFutureInterface<SimulatorControl::
|
|||||||
} else {
|
} else {
|
||||||
qCDebug(simulatorLog) << "Error starting simulator.";
|
qCDebug(simulatorLog) << "Error starting simulator.";
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
qCDebug(simulatorLog) << "Can not start Simulator device. Simulator not in shutdown state."
|
||||||
|
<< simInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!fi.isCanceled()) {
|
if (!fi.isCanceled()) {
|
||||||
@@ -541,5 +566,13 @@ void SimulatorControlPrivate::takeSceenshot(QFutureInterface<SimulatorControl::R
|
|||||||
fi.reportResult(response);
|
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 Internal
|
||||||
} // namespace Ios
|
} // namespace Ios
|
||||||
|
|||||||
@@ -27,7 +27,7 @@
|
|||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QFuture>
|
#include <QFuture>
|
||||||
#include "utils/fileutils.h"
|
#include "utils/fileutils.h"
|
||||||
|
#include <QDebug>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
@@ -50,10 +50,14 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class SimulatorInfo : public SimulatorEntity {
|
class SimulatorInfo : public SimulatorEntity
|
||||||
|
{
|
||||||
|
friend QDebug &operator<<(QDebug &, const SimulatorInfo &info);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool isBooted() const { return state.compare(QStringLiteral("Booted")) == 0; }
|
bool isBooted() const { return state.compare(QStringLiteral("Booted")) == 0; }
|
||||||
bool isShutdown() const { return state.compare(QStringLiteral("Shutdown")) == 0; }
|
bool isShutdown() const { return state.compare(QStringLiteral("Shutdown")) == 0; }
|
||||||
|
bool isShuttingDown() const { return state == "Shutting Down"; }
|
||||||
bool available;
|
bool available;
|
||||||
QString state;
|
QString state;
|
||||||
QString runtimeName;
|
QString runtimeName;
|
||||||
|
|||||||
Reference in New Issue
Block a user