Skip to content
Snippets Groups Projects
Commit f9d2b649 authored by Aurindam Jana's avatar Aurindam Jana
Browse files

QmlDebugging: Query available port


Use QTcpServer instead of TcpPortsGatherer.

Change-Id: I85133c5ae192b407009c5b21df332c9d3d94acda
Reviewed-by: default avatarChristian Kandeler <christian.kandeler@digia.com>
Reviewed-by: default avatarAurindam Jana <aurindam.jana@digia.com>
parent 49f1cd53
No related branches found
No related tags found
No related merge requests found
......@@ -56,11 +56,10 @@
#include <utils/qtcassert.h>
#include <utils/qtcprocess.h>
#include <utils/portlist.h>
#include <utils/tcpportsgatherer.h>
#include <coreplugin/icore.h>
#include <QErrorMessage>
#include <QTcpServer>
using namespace Debugger::Internal;
using namespace ProjectExplorer;
......@@ -385,18 +384,14 @@ static DebuggerStartParameters localStartParameters(RunConfiguration *runConfigu
DeviceKitInformation::device(runConfiguration->target()->kit());
sp.qmlServerAddress = _("127.0.0.1");
QTC_ASSERT(device->type() == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE, return sp);
TcpPortsGatherer portsGatherer;
portsGatherer.update(QAbstractSocket::UnknownNetworkLayerProtocol);
Utils::PortList portList = device->freePorts();
int freePort = portsGatherer.getNextFreePort(&portList);
if (freePort == -1) {
QTcpServer server;
const bool canListen = server.listen(QHostAddress(sp.qmlServerAddress));
if (!canListen) {
if (errorMessage)
*errorMessage = DebuggerPlugin::tr("Not enough free ports for QML debugging. "
"Increase the port range for Desktop device in "
"Device settings.");
*errorMessage = DebuggerPlugin::tr("Not enough free ports for QML debugging. ");
return sp;
}
sp.qmlServerPort = freePort;
sp.qmlServerPort = server.serverPort();
sp.languages |= QmlLanguage;
// Makes sure that all bindings go through the JavaScript engine, so that
......
......@@ -37,7 +37,6 @@
#include <projectexplorer/project.h>
#include <projectexplorer/projectexplorer.h>
#include <utils/qtcprocess.h>
#include <utils/tcpportsgatherer.h>
#include <debugger/debuggerrunner.h>
#include <debugger/debuggerplugin.h>
......@@ -47,6 +46,8 @@
#include <qmlprojectmanager/qmlprojectplugin.h>
#include <QTcpServer>
using namespace ProjectExplorer;
namespace QmlProjectManager {
......@@ -219,17 +220,14 @@ RunControl *QmlProjectRunControlFactory::createDebugRunControl(QmlProjectRunConf
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) {
QTcpServer server;
const bool canListen = server.listen(QHostAddress(params.qmlServerAddress));
if (!canListen) {
if (errorMessage)
*errorMessage = tr("Not enough free ports for QML debugging. Increase the "
"port range for Desktop device in Device settings.");
*errorMessage = tr("Not enough free ports for QML debugging. ");
return 0;
}
params.qmlServerPort = freePort;
params.qmlServerPort = server.serverPort();
params.languages |= Debugger::QmlLanguage;
// Makes sure that all bindings go through the JavaScript engine, so that
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment