From ef7a5836be742b40a3af8f8f71fc8b7e595142cc Mon Sep 17 00:00:00 2001 From: Fawzi Mohamed Date: Fri, 14 Feb 2014 01:05:59 +0100 Subject: [PATCH] ios: explicitly stop an application when running on the same device iOS devices can run an application at a time. Change-Id: I85a24ff32fbee571830a4bc4be8b18259f87924a Reviewed-by: Daniel Teske --- src/plugins/ios/iosrunfactories.cpp | 17 ++++++++++++++--- src/plugins/ios/iosrunfactories.h | 2 ++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/plugins/ios/iosrunfactories.cpp b/src/plugins/ios/iosrunfactories.cpp index b7c78e87983..760d26d13dc 100644 --- a/src/plugins/ios/iosrunfactories.cpp +++ b/src/plugins/ios/iosrunfactories.cpp @@ -37,6 +37,7 @@ #include #include +#include #include #include #include @@ -46,7 +47,6 @@ #include #include - using namespace ProjectExplorer; using namespace QmakeProjectManager; @@ -166,10 +166,21 @@ RunControl *IosRunControlFactory::create(RunConfiguration *runConfig, Q_ASSERT(canRun(runConfig, mode)); IosRunConfiguration *rc = qobject_cast(runConfig); Q_ASSERT(rc); + RunControl *res = 0; + Core::Id devId = ProjectExplorer::DeviceKitInformation::deviceId(rc->target()->kit()); + // The device can only run an application at a time, if an app is running stop it. + if (m_activeRunControls.contains(devId)) { + QPointer activeRunControl = m_activeRunControls[devId]; + activeRunControl->stop(); + m_activeRunControls.remove(devId); + } if (mode == NormalRunMode) - return new Ios::Internal::IosRunControl(rc); + res = new Ios::Internal::IosRunControl(rc); else - return IosDebugSupport::createDebugRunControl(rc, errorMessage); + res = IosDebugSupport::createDebugRunControl(rc, errorMessage); + if (devId.isValid()) + m_activeRunControls[devId] = res; + return res; } } // namespace Internal diff --git a/src/plugins/ios/iosrunfactories.h b/src/plugins/ios/iosrunfactories.h index 6f86be5f0a8..3d66090fd40 100644 --- a/src/plugins/ios/iosrunfactories.h +++ b/src/plugins/ios/iosrunfactories.h @@ -85,6 +85,8 @@ public: ProjectExplorer::RunControl *create(ProjectExplorer::RunConfiguration *runConfiguration, ProjectExplorer::RunMode mode, QString *errorMessage) QTC_OVERRIDE; +private: + mutable QMap > m_activeRunControls; }; } // namespace Internal