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