diff --git a/src/plugins/ios/iosrunner.cpp b/src/plugins/ios/iosrunner.cpp index 02d47e914fc..b37bd681bcb 100644 --- a/src/plugins/ios/iosrunner.cpp +++ b/src/plugins/ios/iosrunner.cpp @@ -60,18 +60,29 @@ using namespace Tasking; namespace Ios::Internal { +static QString identifierForRunControl(RunControl *runControl) +{ + const IosDeviceTypeAspect::Data *data = runControl->aspect(); + return data ? data->deviceType.identifier : QString(); +} + static void stopRunningRunControl(RunControl *runControl) { static QMap> activeRunControls; + // clean up deleted + Utils::erase(activeRunControls, [](const QPointer &rc) { return !rc; }); + Target *target = runControl->target(); - Id devId = DeviceKitAspect::deviceId(target->kit()); + const Id devId = DeviceKitAspect::deviceId(target->kit()); + const QString identifier = identifierForRunControl(runControl); // The device can only run an application at a time, if an app is running stop it. - if (activeRunControls.contains(devId)) { - if (QPointer activeRunControl = activeRunControls[devId]) + if (QPointer activeRunControl = activeRunControls[devId]) { + if (identifierForRunControl(activeRunControl) == identifier) { activeRunControl->initiateStop(); - activeRunControls.remove(devId); + activeRunControls.remove(devId); + } } if (devId.isValid()) diff --git a/src/plugins/projectexplorer/appoutputpane.cpp b/src/plugins/projectexplorer/appoutputpane.cpp index 898acaba2a9..806628668f2 100644 --- a/src/plugins/projectexplorer/appoutputpane.cpp +++ b/src/plugins/projectexplorer/appoutputpane.cpp @@ -391,14 +391,14 @@ void AppOutputPane::createNewOutputWindow(RunControl *rc) const CommandLine thisCommand = rc->commandLine(); const FilePath thisWorkingDirectory = rc->workingDirectory(); const Environment thisEnvironment = rc->environment(); - const auto tab = std::find_if(m_runControlTabs.begin(), m_runControlTabs.end(), - [&](const RunControlTab &tab) { - if (!tab.runControl || tab.runControl->isRunning() || tab.runControl->isStarting()) - return false; - return thisCommand == tab.runControl->commandLine() - && thisWorkingDirectory == tab.runControl->workingDirectory() - && thisEnvironment == tab.runControl->environment(); - }); + const auto tab = std::find_if( + m_runControlTabs.begin(), m_runControlTabs.end(), [&](const RunControlTab &tab) { + if (!tab.runControl || !tab.runControl->isStopped()) + return false; + return thisCommand == tab.runControl->commandLine() + && thisWorkingDirectory == tab.runControl->workingDirectory() + && thisEnvironment == tab.runControl->environment(); + }); if (tab != m_runControlTabs.end()) { // Reuse this tab if (tab->runControl)