diff options
author | Vikas Pachdha <vikas.pachdha@qt.io> | 2017-04-28 08:27:10 +0200 |
---|---|---|
committer | Vikas Pachdha <vikas.pachdha@qt.io> | 2017-05-02 10:32:07 +0000 |
commit | a4a78ae8b116d7f16a141700bbda6da722e0699d (patch) | |
tree | 5baa69114101853b051a3bcd35b2ff74d81bd81d | |
parent | f2e296f7c79786dd5b6e520df38b588a2e9e5fd8 (diff) | |
download | qt-creator-a4a78ae8b116d7f16a141700bbda6da722e0699d.tar.gz |
iOS: Fix run without deploy on iOS simulator
Task-number: QTCREATORBUG-18107
Change-Id: Ie847cdab672ff2df7af0c2fee742901de0783861
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
-rw-r--r-- | src/plugins/ios/iostoolhandler.cpp | 5 | ||||
-rw-r--r-- | src/plugins/ios/simulatorcontrol.cpp | 37 | ||||
-rw-r--r-- | src/plugins/ios/simulatorcontrol.h | 8 |
3 files changed, 43 insertions, 7 deletions
diff --git a/src/plugins/ios/iostoolhandler.cpp b/src/plugins/ios/iostoolhandler.cpp index 5330d5ce67..4795d922a0 100644 --- a/src/plugins/ios/iostoolhandler.cpp +++ b/src/plugins/ios/iostoolhandler.cpp @@ -848,13 +848,12 @@ void IosSimulatorToolHandlerPrivate::requestRunApp(const QString &appBundlePath, } auto onSimulatorStart = [this, extraArgs] (const SimulatorControl::ResponseData &response) { - if (isResponseValid(response)) + if (!isResponseValid(response)) return; if (response.success) { launchAppOnSimulator(extraArgs); } else { - errorMsg(IosToolHandler::tr("Application launch on Simulator failed. Simulator not running.") - .arg(bundlePath)); + errorMsg(IosToolHandler::tr("Application launch on Simulator failed. Simulator not running.")); didStartApp(bundlePath, deviceId, Ios::IosToolHandler::Failure); } }; diff --git a/src/plugins/ios/simulatorcontrol.cpp b/src/plugins/ios/simulatorcontrol.cpp index a533152b43..84b5b094de 100644 --- a/src/plugins/ios/simulatorcontrol.cpp +++ b/src/plugins/ios/simulatorcontrol.cpp @@ -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 diff --git a/src/plugins/ios/simulatorcontrol.h b/src/plugins/ios/simulatorcontrol.h index 3e94379c70..5c95d00f22 100644 --- a/src/plugins/ios/simulatorcontrol.h +++ b/src/plugins/ios/simulatorcontrol.h @@ -27,7 +27,7 @@ #include <QObject> #include <QFuture> #include "utils/fileutils.h" - +#include <QDebug> #include <memory> QT_BEGIN_NAMESPACE @@ -50,10 +50,14 @@ public: } }; -class SimulatorInfo : public SimulatorEntity { +class SimulatorInfo : public SimulatorEntity +{ + friend QDebug &operator<<(QDebug &, const SimulatorInfo &info); + public: bool isBooted() const { return state.compare(QStringLiteral("Booted")) == 0; } bool isShutdown() const { return state.compare(QStringLiteral("Shutdown")) == 0; } + bool isShuttingDown() const { return state == "Shutting Down"; } bool available; QString state; QString runtimeName; |