forked from qt-creator/qt-creator
Use Utils::Port where possible
This solves the ambiguity between 0 and -1 being the "invalid" port. Change-Id: I3bac11dd4117bb1820fbd58186699925b73df1c5 Reviewed-by: hjk <hjk@theqtcompany.com>
This commit is contained in:
@@ -97,13 +97,13 @@ void IosAnalyzeSupport::qmlServerReady()
|
||||
m_runControl->notifyRemoteSetupDone(m_qmlPort);
|
||||
}
|
||||
|
||||
void IosAnalyzeSupport::handleServerPorts(int gdbServerPort, int qmlPort)
|
||||
void IosAnalyzeSupport::handleServerPorts(Utils::Port gdbServerPort, Utils::Port qmlPort)
|
||||
{
|
||||
Q_UNUSED(gdbServerPort);
|
||||
m_qmlPort = qmlPort;
|
||||
}
|
||||
|
||||
void IosAnalyzeSupport::handleGotInferiorPid(qint64 pid, int qmlPort)
|
||||
void IosAnalyzeSupport::handleGotInferiorPid(qint64 pid, Utils::Port qmlPort)
|
||||
{
|
||||
Q_UNUSED(pid);
|
||||
m_qmlPort = qmlPort;
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include "iosrunconfiguration.h"
|
||||
|
||||
#include <qmldebug/qmloutputparser.h>
|
||||
#include <utils/port.h>
|
||||
|
||||
#include <QProcess>
|
||||
#include <QObject>
|
||||
@@ -51,8 +52,8 @@ public:
|
||||
|
||||
private:
|
||||
void qmlServerReady();
|
||||
void handleServerPorts(int gdbServerFd, int qmlPort);
|
||||
void handleGotInferiorPid(qint64 pid, int qmlPort);
|
||||
void handleServerPorts(Utils::Port gdbServerPort, Utils::Port qmlPort);
|
||||
void handleGotInferiorPid(qint64 pid, Utils::Port qmlPort);
|
||||
void handleRemoteProcessFinished(bool cleanEnd);
|
||||
|
||||
void handleRemoteOutput(const QString &output);
|
||||
@@ -61,7 +62,7 @@ private:
|
||||
Debugger::AnalyzerRunControl *m_runControl;
|
||||
IosRunner * const m_runner;
|
||||
QmlDebug::QmlOutputParser m_outputParser;
|
||||
int m_qmlPort;
|
||||
Utils::Port m_qmlPort;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
@@ -181,18 +181,19 @@ IosDebugSupport::~IosDebugSupport()
|
||||
{
|
||||
}
|
||||
|
||||
void IosDebugSupport::handleServerPorts(int gdbServerPort, int qmlPort)
|
||||
void IosDebugSupport::handleServerPorts(Utils::Port gdbServerPort, Utils::Port qmlPort)
|
||||
{
|
||||
RemoteSetupResult result;
|
||||
result.gdbServerPort = gdbServerPort;
|
||||
result.qmlServerPort = qmlPort;
|
||||
result.success = gdbServerPort > 0 || (m_runner && !m_runner->cppDebug() && qmlPort > 0);
|
||||
result.success = gdbServerPort.isValid()
|
||||
|| (m_runner && !m_runner->cppDebug() && qmlPort.isValid());
|
||||
if (!result.success)
|
||||
result.reason = tr("Could not get debug server file descriptor.");
|
||||
m_runControl->notifyEngineRemoteSetupFinished(result);
|
||||
}
|
||||
|
||||
void IosDebugSupport::handleGotInferiorPid(qint64 pid, int qmlPort)
|
||||
void IosDebugSupport::handleGotInferiorPid(qint64 pid, Utils::Port qmlPort)
|
||||
{
|
||||
RemoteSetupResult result;
|
||||
result.qmlServerPort = qmlPort;
|
||||
|
||||
@@ -50,8 +50,8 @@ public:
|
||||
~IosDebugSupport();
|
||||
|
||||
private:
|
||||
void handleServerPorts(int gdbServerFd, int qmlPort);
|
||||
void handleGotInferiorPid(qint64, int qmlPort);
|
||||
void handleServerPorts(Utils::Port gdbServerPort, Utils::Port qmlPort);
|
||||
void handleGotInferiorPid(qint64, Utils::Port qmlPort);
|
||||
void handleRemoteProcessFinished(bool cleanEnd);
|
||||
|
||||
void handleRemoteOutput(const QString &output);
|
||||
|
||||
@@ -88,8 +88,8 @@ IosDevice::IosDevice()
|
||||
setDisplayName(IosDevice::name());
|
||||
setDeviceState(DeviceDisconnected);
|
||||
Utils::PortList ports;
|
||||
ports.addRange(Constants::IOS_DEVICE_PORT_START,
|
||||
Constants::IOS_DEVICE_PORT_END);
|
||||
ports.addRange(Utils::Port(Constants::IOS_DEVICE_PORT_START),
|
||||
Utils::Port(Constants::IOS_DEVICE_PORT_END));
|
||||
setFreePorts(ports);
|
||||
}
|
||||
|
||||
@@ -200,12 +200,12 @@ QString IosDevice::osVersion() const
|
||||
return m_extraInfo.value(QLatin1String("osVersion"));
|
||||
}
|
||||
|
||||
quint16 IosDevice::nextPort() const
|
||||
Utils::Port IosDevice::nextPort() const
|
||||
{
|
||||
// use qrand instead?
|
||||
if (++m_lastPort >= Constants::IOS_DEVICE_PORT_END)
|
||||
m_lastPort = Constants::IOS_DEVICE_PORT_START;
|
||||
return m_lastPort;
|
||||
return Utils::Port(m_lastPort);
|
||||
}
|
||||
|
||||
bool IosDevice::canAutoDetectPorts() const
|
||||
|
||||
@@ -66,7 +66,7 @@ public:
|
||||
QString uniqueDeviceID() const;
|
||||
IosDevice(const QString &uid);
|
||||
QString osVersion() const;
|
||||
quint16 nextPort() const;
|
||||
Utils::Port nextPort() const;
|
||||
bool canAutoDetectPorts() const override;
|
||||
|
||||
static QString name();
|
||||
|
||||
@@ -76,7 +76,7 @@ QString IosRunner::bundlePath()
|
||||
QStringList IosRunner::extraArgs()
|
||||
{
|
||||
QStringList res = m_arguments;
|
||||
if (m_qmlPort != 0)
|
||||
if (m_qmlPort.isValid())
|
||||
res << QmlDebug::qmlDebugTcpArguments(m_qmlDebugServices, m_qmlPort);
|
||||
return res;
|
||||
}
|
||||
@@ -113,7 +113,7 @@ void IosRunner::start()
|
||||
emit finished(m_cleanExit);
|
||||
}
|
||||
m_cleanExit = false;
|
||||
m_qmlPort = 0;
|
||||
m_qmlPort = Utils::Port();
|
||||
if (!QFileInfo::exists(m_bundleDir)) {
|
||||
TaskHub::addTask(Task::Warning,
|
||||
tr("Could not find %1.").arg(m_bundleDir),
|
||||
@@ -177,7 +177,8 @@ void IosRunner::handleDidStartApp(IosToolHandler *handler, const QString &bundle
|
||||
}
|
||||
|
||||
void IosRunner::handleGotServerPorts(IosToolHandler *handler, const QString &bundlePath,
|
||||
const QString &deviceId, int gdbPort, int qmlPort)
|
||||
const QString &deviceId, Utils::Port gdbPort,
|
||||
Utils::Port qmlPort)
|
||||
{
|
||||
Q_UNUSED(bundlePath); Q_UNUSED(deviceId);
|
||||
m_qmlPort = qmlPort;
|
||||
@@ -200,8 +201,8 @@ void IosRunner::handleAppOutput(IosToolHandler *handler, const QString &output)
|
||||
QRegExp qmlPortRe(QLatin1String("QML Debugger: Waiting for connection on port ([0-9]+)..."));
|
||||
int index = qmlPortRe.indexIn(output);
|
||||
QString res(output);
|
||||
if (index != -1 && m_qmlPort)
|
||||
res.replace(qmlPortRe.cap(1), QString::number(m_qmlPort));
|
||||
if (index != -1 && m_qmlPort.isValid())
|
||||
res.replace(qmlPortRe.cap(1), QString::number(m_qmlPort.number()));
|
||||
emit appOutput(res);
|
||||
}
|
||||
|
||||
@@ -222,8 +223,8 @@ void IosRunner::handleErrorMsg(IosToolHandler *handler, const QString &msg)
|
||||
}
|
||||
QRegExp qmlPortRe(QLatin1String("QML Debugger: Waiting for connection on port ([0-9]+)..."));
|
||||
int index = qmlPortRe.indexIn(msg);
|
||||
if (index != -1 && m_qmlPort)
|
||||
res.replace(qmlPortRe.cap(1), QString::number(m_qmlPort));
|
||||
if (index != -1 && m_qmlPort.isValid())
|
||||
res.replace(qmlPortRe.cap(1), QString::number(m_qmlPort.number()));
|
||||
emit errorMsg(res);
|
||||
}
|
||||
|
||||
|
||||
@@ -66,8 +66,8 @@ public slots:
|
||||
|
||||
signals:
|
||||
void didStartApp(Ios::IosToolHandler::OpStatus status);
|
||||
void gotServerPorts(int gdbPort, int qmlPort);
|
||||
void gotInferiorPid(qint64 pid, int);
|
||||
void gotServerPorts(Utils::Port gdbPort, Utils::Port qmlPort);
|
||||
void gotInferiorPid(qint64 pid, Utils::Port qmlPort);
|
||||
void appOutput(const QString &output);
|
||||
void errorMsg(const QString &msg);
|
||||
void finished(bool cleanExit);
|
||||
@@ -76,7 +76,7 @@ private:
|
||||
void handleDidStartApp(Ios::IosToolHandler *handler, const QString &bundlePath,
|
||||
const QString &deviceId, Ios::IosToolHandler::OpStatus status);
|
||||
void handleGotServerPorts(Ios::IosToolHandler *handler, const QString &bundlePath,
|
||||
const QString &deviceId, int gdbPort, int qmlPort);
|
||||
const QString &deviceId, Utils::Port gdbPort, Utils::Port qmlPort);
|
||||
void handleGotInferiorPid(Ios::IosToolHandler *handler, const QString &bundlePath,
|
||||
const QString &deviceId, qint64 pid);
|
||||
void handleAppOutput(Ios::IosToolHandler *handler, const QString &output);
|
||||
@@ -93,7 +93,7 @@ private:
|
||||
QmlDebug::QmlDebugServicesPreset m_qmlDebugServices;
|
||||
|
||||
bool m_cleanExit;
|
||||
quint16 m_qmlPort;
|
||||
Utils::Port m_qmlPort;
|
||||
qint64 m_pid;
|
||||
};
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include "iostoolhandler.h"
|
||||
|
||||
#include <projectexplorer/kitinformation.h>
|
||||
#include <utils/port.h>
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QMapIterator>
|
||||
@@ -171,7 +172,7 @@ QVariantMap IosSimulator::toMap() const
|
||||
return res;
|
||||
}
|
||||
|
||||
quint16 IosSimulator::nextPort() const
|
||||
Utils::Port IosSimulator::nextPort() const
|
||||
{
|
||||
for (int i = 0; i < 100; ++i) {
|
||||
// use qrand instead?
|
||||
@@ -192,7 +193,7 @@ quint16 IosSimulator::nextPort() const
|
||||
|| portVerifier.exitCode() != 0)
|
||||
break;
|
||||
}
|
||||
return m_lastPort;
|
||||
return Utils::Port(m_lastPort);
|
||||
}
|
||||
|
||||
bool IosSimulator::canAutoDetectPorts() const
|
||||
|
||||
@@ -79,7 +79,7 @@ public:
|
||||
ProjectExplorer::DeviceProcessSignalOperation::Ptr signalOperation() const override;
|
||||
void fromMap(const QVariantMap &map) override;
|
||||
QVariantMap toMap() const override;
|
||||
quint16 nextPort() const;
|
||||
Utils::Port nextPort() const;
|
||||
bool canAutoDetectPorts() const override;
|
||||
|
||||
ProjectExplorer::IDevice::Ptr clone() const override;
|
||||
|
||||
@@ -141,8 +141,8 @@ public:
|
||||
IosToolHandler::OpStatus status);
|
||||
void didStartApp(const QString &bundlePath, const QString &deviceId,
|
||||
IosToolHandler::OpStatus status);
|
||||
void gotServerPorts(const QString &bundlePath, const QString &deviceId, int gdbPort,
|
||||
int qmlPort);
|
||||
void gotServerPorts(const QString &bundlePath, const QString &deviceId, Utils::Port gdbPort,
|
||||
Utils::Port qmlPort);
|
||||
void gotInferiorPid(const QString &bundlePath, const QString &deviceId, qint64 pid);
|
||||
void deviceInfo(const QString &deviceId, const IosToolHandler::Dict &info);
|
||||
void appOutput(const QString &output);
|
||||
@@ -306,8 +306,8 @@ void IosToolHandlerPrivate::didStartApp(const QString &bundlePath, const QString
|
||||
emit q->didStartApp(q, bundlePath, deviceId, status);
|
||||
}
|
||||
|
||||
void IosToolHandlerPrivate::gotServerPorts(const QString &bundlePath,
|
||||
const QString &deviceId, int gdbPort, int qmlPort)
|
||||
void IosToolHandlerPrivate::gotServerPorts(const QString &bundlePath, const QString &deviceId,
|
||||
Utils::Port gdbPort, Utils::Port qmlPort)
|
||||
{
|
||||
emit q->gotServerPorts(q, bundlePath, deviceId, gdbPort, qmlPort);
|
||||
}
|
||||
@@ -445,8 +445,10 @@ void IosToolHandlerPrivate::processXml()
|
||||
} else if (elName == QLatin1String("server_ports")) {
|
||||
stack.append(ParserState(ParserState::ServerPorts));
|
||||
QXmlStreamAttributes attributes = outputParser.attributes();
|
||||
int gdbServerPort = attributes.value(QLatin1String("gdb_server")).toString().toInt();
|
||||
int qmlServerPort = attributes.value(QLatin1String("qml_server")).toString().toInt();
|
||||
Utils::Port gdbServerPort(
|
||||
attributes.value(QLatin1String("gdb_server")).toString().toInt());
|
||||
Utils::Port qmlServerPort(
|
||||
attributes.value(QLatin1String("qml_server")).toString().toInt());
|
||||
gotServerPorts(bundlePath, deviceId, gdbServerPort, qmlServerPort);
|
||||
} else {
|
||||
qCWarning(toolHandlerLog) << "unexpected element " << elName;
|
||||
|
||||
@@ -25,6 +25,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <utils/port.h>
|
||||
|
||||
#include <QObject>
|
||||
#include <QMap>
|
||||
#include <QString>
|
||||
@@ -72,7 +74,7 @@ signals:
|
||||
void didStartApp(Ios::IosToolHandler *handler, const QString &bundlePath,
|
||||
const QString &deviceId, Ios::IosToolHandler::OpStatus status);
|
||||
void gotServerPorts(Ios::IosToolHandler *handler, const QString &bundlePath,
|
||||
const QString &deviceId, int gdbPort, int qmlPort);
|
||||
const QString &deviceId, Utils::Port gdbPort, Utils::Port qmlPort);
|
||||
void gotInferiorPid(Ios::IosToolHandler *handler, const QString &bundlePath,
|
||||
const QString &deviceId, qint64 pid);
|
||||
void deviceInfo(Ios::IosToolHandler *handler, const QString &deviceId,
|
||||
|
||||
Reference in New Issue
Block a user