forked from qt-creator/qt-creator
QmlProfiler: Query available port
Use QTcpServer instead of TcpPortsGatherer. Change-Id: I12c53ae421fa559a7e71dd5855add2aff00ce33b Reviewed-by: Christiaan Janssen <christiaan.janssen@digia.com>
This commit is contained in:
@@ -47,11 +47,11 @@
|
|||||||
#include <projectexplorer/localapplicationrunconfiguration.h>
|
#include <projectexplorer/localapplicationrunconfiguration.h>
|
||||||
#include <qmldebug/qmloutputparser.h>
|
#include <qmldebug/qmloutputparser.h>
|
||||||
#include <remotelinux/remotelinuxrunconfiguration.h>
|
#include <remotelinux/remotelinuxrunconfiguration.h>
|
||||||
#include <utils/tcpportsgatherer.h>
|
|
||||||
|
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
#include <QTcpServer>
|
||||||
|
|
||||||
using namespace Analyzer;
|
using namespace Analyzer;
|
||||||
using namespace ProjectExplorer;
|
using namespace ProjectExplorer;
|
||||||
@@ -121,13 +121,10 @@ QmlProfilerEngine::QmlProfilerEnginePrivate::createRunner(ProjectExplorer::RunCo
|
|||||||
const ProjectExplorer::IDevice::ConstPtr device =
|
const ProjectExplorer::IDevice::ConstPtr device =
|
||||||
ProjectExplorer::DeviceKitInformation::device(runConfiguration->target()->kit());
|
ProjectExplorer::DeviceKitInformation::device(runConfiguration->target()->kit());
|
||||||
QTC_ASSERT(device->type() == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE, return 0);
|
QTC_ASSERT(device->type() == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE, return 0);
|
||||||
Utils::TcpPortsGatherer portsGatherer;
|
QTcpServer server;
|
||||||
portsGatherer.update(QAbstractSocket::UnknownNetworkLayerProtocol);
|
if (!server.listen(QHostAddress(QLatin1String("127.0.0.1"))))
|
||||||
Utils::PortList portList = device->freePorts();
|
|
||||||
int freePort = portsGatherer.getNextFreePort(&portList);
|
|
||||||
if (freePort == -1)
|
|
||||||
return 0;
|
return 0;
|
||||||
conf.port = freePort;
|
conf.port = server.serverPort();
|
||||||
runner = new LocalQmlProfilerRunner(conf, parent);
|
runner = new LocalQmlProfilerRunner(conf, parent);
|
||||||
}
|
}
|
||||||
return runner;
|
return runner;
|
||||||
|
@@ -48,7 +48,6 @@
|
|||||||
#include <utils/fancymainwindow.h>
|
#include <utils/fancymainwindow.h>
|
||||||
#include <utils/fileinprojectfinder.h>
|
#include <utils/fileinprojectfinder.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
#include <utils/tcpportsgatherer.h>
|
|
||||||
#include <projectexplorer/environmentaspect.h>
|
#include <projectexplorer/environmentaspect.h>
|
||||||
#include <projectexplorer/projectexplorer.h>
|
#include <projectexplorer/projectexplorer.h>
|
||||||
#include <projectexplorer/project.h>
|
#include <projectexplorer/project.h>
|
||||||
@@ -85,6 +84,7 @@
|
|||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QTime>
|
#include <QTime>
|
||||||
|
#include <QTcpServer>
|
||||||
|
|
||||||
using namespace Core;
|
using namespace Core;
|
||||||
using namespace Core::Constants;
|
using namespace Core::Constants;
|
||||||
@@ -343,13 +343,10 @@ AnalyzerStartParameters QmlProfilerTool::createStartParameters(RunConfiguration
|
|||||||
const ProjectExplorer::IDevice::ConstPtr device =
|
const ProjectExplorer::IDevice::ConstPtr device =
|
||||||
ProjectExplorer::DeviceKitInformation::device(runConfiguration->target()->kit());
|
ProjectExplorer::DeviceKitInformation::device(runConfiguration->target()->kit());
|
||||||
if (device->type() == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE) {
|
if (device->type() == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE) {
|
||||||
Utils::TcpPortsGatherer portsGatherer;
|
QTcpServer server;
|
||||||
portsGatherer.update(QAbstractSocket::UnknownNetworkLayerProtocol);
|
if (!server.listen(QHostAddress(sp.connParams.host)))
|
||||||
Utils::PortList portList = device->freePorts();
|
|
||||||
int freePort = portsGatherer.getNextFreePort(&portList);
|
|
||||||
if (freePort == -1)
|
|
||||||
return sp;
|
return sp;
|
||||||
sp.connParams.port = freePort;
|
sp.connParams.port = server.serverPort();
|
||||||
}
|
}
|
||||||
sp.startMode = StartQml;
|
sp.startMode = StartQml;
|
||||||
return sp;
|
return sp;
|
||||||
|
Reference in New Issue
Block a user