From f8bc2cbae550a18d4a36e7603b480f7668a53f30 Mon Sep 17 00:00:00 2001 From: Aurindam Jana Date: Wed, 20 Mar 2013 13:00:10 +0100 Subject: DeviceManager: Allow user to configure desktop device Show desktop device in the Devices options page. Allow user to configure the port range for the desktop. These ports can then be used by others such as QML Debugger. Change-Id: I8c4a96207e54f58d1e9bc18c417cb378dc9f70c2 Reviewed-by: Christian Kandeler --- .../qmlprojectmanager/qmlprojectruncontrol.cpp | 42 ++++++++++++++++------ 1 file changed, 31 insertions(+), 11 deletions(-) (limited to 'src/plugins/qmlprojectmanager/qmlprojectruncontrol.cpp') diff --git a/src/plugins/qmlprojectmanager/qmlprojectruncontrol.cpp b/src/plugins/qmlprojectmanager/qmlprojectruncontrol.cpp index 7ae086727f..8612ab28ae 100644 --- a/src/plugins/qmlprojectmanager/qmlprojectruncontrol.cpp +++ b/src/plugins/qmlprojectmanager/qmlprojectruncontrol.cpp @@ -33,9 +33,12 @@ #include #include #include +#include #include #include #include +#include +#include #include #include @@ -199,26 +202,43 @@ RunControl *QmlProjectRunControlFactory::createDebugRunControl(QmlProjectRunConf Debugger::DebuggerStartParameters params; params.startMode = Debugger::StartInternal; params.executable = runConfig->observerPath(); - params.qmlServerAddress = QLatin1String("127.0.0.1"); - params.qmlServerPort = runConfig->debuggerAspect()->qmlDebugServerPort(); - params.processArgs = QString::fromLatin1("-qmljsdebugger=port:%1,block").arg(params.qmlServerPort); - params.processArgs += QLatin1Char(' ') + runConfig->viewerArguments(); + params.processArgs = runConfig->viewerArguments(); params.workingDirectory = runConfig->workingDirectory(); params.environment = runConfig->environment(); params.displayName = runConfig->displayName(); params.projectSourceDirectory = runConfig->target()->project()->projectDirectory(); params.projectSourceFiles = runConfig->target()->project()->files(Project::ExcludeGeneratedFiles); - if (runConfig->debuggerAspect()->useQmlDebugger()) + if (runConfig->debuggerAspect()->useQmlDebugger()) { + const ProjectExplorer::IDevice::ConstPtr device = + DeviceKitInformation::device(runConfig->target()->kit()); + params.qmlServerAddress = QLatin1String("127.0.0.1"); + QTC_ASSERT(device->type() == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE, return 0); + Utils::TcpPortsGatherer portsGatherer; + portsGatherer.update(QAbstractSocket::UnknownNetworkLayerProtocol); + Utils::PortList portList = device->freePorts(); + int freePort = portsGatherer.getNextFreePort(&portList); + if (freePort == -1) { + if (errorMessage) + *errorMessage = tr("Not enough free ports for QML debugging. Increase the " + "port range for Desktop device in Device settings."); + return 0; + } + params.qmlServerPort = freePort; params.languages |= Debugger::QmlLanguage; + + // Makes sure that all bindings go through the JavaScript engine, so that + // breakpoints are actually hit! + const QString optimizerKey = QLatin1String("QML_DISABLE_OPTIMIZER"); + if (!params.environment.hasKey(optimizerKey)) + params.environment.set(optimizerKey, QLatin1String("1")); + + Utils::QtcProcess::addArg(¶ms.processArgs, + QString::fromLatin1("-qmljsdebugger=port:%1,block").arg( + params.qmlServerPort)); + } if (runConfig->debuggerAspect()->useCppDebugger()) params.languages |= Debugger::CppLanguage; - // Makes sure that all bindings go through the JavaScript engine, so that - // breakpoints are actually hit! - const QString optimizerKey = QLatin1String("QML_DISABLE_OPTIMIZER"); - if (!params.environment.hasKey(optimizerKey)) - params.environment.set(optimizerKey, QLatin1String("1")); - if (params.executable.isEmpty()) { QmlProjectPlugin::showQmlObserverToolWarning(); errorMessage->clear(); // hack, we already showed a error message -- cgit v1.2.1