summaryrefslogtreecommitdiff
path: root/src/plugins/ios/iosrunfactories.cpp
diff options
context:
space:
mode:
authorFawzi Mohamed <fawzi.mohamed@digia.com>2013-11-26 15:18:49 +0100
committerFawzi Mohamed <fawzi.mohamed@digia.com>2013-11-28 21:23:38 +0100
commitf6542e2abed9e972c24223e063f3288065ae6fbd (patch)
tree7b6fb3e87d1a4fac03b03a18cbd27cbdc2dd0c49 /src/plugins/ios/iosrunfactories.cpp
parent4bd0fcbf8d9777347448dc5d898a8ca27c007d89 (diff)
downloadqt-creator-f6542e2abed9e972c24223e063f3288065ae6fbd.tar.gz
ios: disable run button while an application is running
Task-number: QTCREATORBUG-10670 Change-Id: I23b553984b2c1848983299613004cbd910dc92dc Reviewed-by: Fawzi Mohamed <fawzi.mohamed@digia.com>
Diffstat (limited to 'src/plugins/ios/iosrunfactories.cpp')
-rw-r--r--src/plugins/ios/iosrunfactories.cpp30
1 files changed, 27 insertions, 3 deletions
diff --git a/src/plugins/ios/iosrunfactories.cpp b/src/plugins/ios/iosrunfactories.cpp
index e9c8219784..c4ad3fcafe 100644
--- a/src/plugins/ios/iosrunfactories.cpp
+++ b/src/plugins/ios/iosrunfactories.cpp
@@ -157,7 +157,26 @@ bool IosRunControlFactory::canRun(RunConfiguration *runConfiguration,
{
if (mode != NormalRunMode && mode != DebugRunMode)
return false;
- return qobject_cast<IosRunConfiguration *>(runConfiguration);
+ IosRunConfiguration *rc = qobject_cast<IosRunConfiguration *>(runConfiguration);
+ if (!rc)
+ return false;
+
+ IDevice::ConstPtr device = DeviceKitInformation::device(rc->target()->kit());
+ if (!device || device->deviceState() != IDevice::DeviceReadyToUse)
+ return false;
+
+ // The device can only run the same application once, any subsequent runs will
+ // not launch a second instance. Disable the Run button if the application is already
+ // running on the device.
+ if (m_activeRunControls.contains(device->id())) {
+ QPointer<ProjectExplorer::RunControl> activeRunControl = m_activeRunControls[device->id()];
+ if (activeRunControl && activeRunControl.data()->isRunning())
+ return false;
+ else
+ m_activeRunControls.remove(device->id());
+ }
+
+ return rc;
}
RunControl *IosRunControlFactory::create(RunConfiguration *runConfig,
@@ -166,10 +185,15 @@ RunControl *IosRunControlFactory::create(RunConfiguration *runConfig,
Q_ASSERT(canRun(runConfig, mode));
IosRunConfiguration *rc = qobject_cast<IosRunConfiguration *>(runConfig);
Q_ASSERT(rc);
+ RunControl *res = 0;
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);
+ IDevice::ConstPtr device = DeviceKitInformation::device(rc->target()->kit());
+ if (device)
+ m_activeRunControls[device->id()] = res;
+ return res;
}
} // namespace Internal