diff --git a/src/plugins/ios/iosrunfactories.cpp b/src/plugins/ios/iosrunfactories.cpp index b7c78e87983e6c5691087cdc0147125160f1aafc..760d26d13dcd061d11a8db1da32118612f4f5296 100644 --- a/src/plugins/ios/iosrunfactories.cpp +++ b/src/plugins/ios/iosrunfactories.cpp @@ -37,6 +37,7 @@ #include <projectexplorer/project.h> #include <projectexplorer/projectexplorerconstants.h> +#include <projectexplorer/projectexplorer.h> #include <projectexplorer/target.h> #include <debugger/debuggerconstants.h> #include <qmakeprojectmanager/qmakeproject.h> @@ -46,7 +47,6 @@ #include <qtsupport/qtsupportconstants.h> #include <coreplugin/id.h> - using namespace ProjectExplorer; using namespace QmakeProjectManager; @@ -166,10 +166,21 @@ RunControl *IosRunControlFactory::create(RunConfiguration *runConfig, Q_ASSERT(canRun(runConfig, mode)); IosRunConfiguration *rc = qobject_cast<IosRunConfiguration *>(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<ProjectExplorer::RunControl> 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 6f86be5f0a84afaef3364341700d87ea61cc8d50..3d66090fd400392711f328c8ed81a6c3fbf994a7 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<Core::Id, QPointer<ProjectExplorer::RunControl> > m_activeRunControls; }; } // namespace Internal