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:
@@ -79,12 +79,12 @@ AndroidAnalyzeSupport::AndroidAnalyzeSupport(AndroidRunConfiguration *runConfig,
|
||||
[runner]() { runner->start(); });
|
||||
|
||||
connect(&m_outputParser, &QmlDebug::QmlOutputParser::waitingForConnectionOnPort,
|
||||
[this, runControl](quint16) {
|
||||
[this, runControl](Utils::Port) {
|
||||
runControl->notifyRemoteSetupDone(m_qmlPort);
|
||||
});
|
||||
|
||||
connect(runner, &AndroidRunner::remoteProcessStarted,
|
||||
[this](int, int qmlPort) {
|
||||
[this](Utils::Port, Utils::Port qmlPort) {
|
||||
m_qmlPort = qmlPort;
|
||||
});
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ public:
|
||||
|
||||
private:
|
||||
QmlDebug::QmlOutputParser m_outputParser;
|
||||
int m_qmlPort;
|
||||
Utils::Port m_qmlPort;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
@@ -171,7 +171,7 @@ AndroidDebugSupport::AndroidDebugSupport(AndroidRunConfiguration *runConfig,
|
||||
});
|
||||
}
|
||||
|
||||
void AndroidDebugSupport::handleRemoteProcessStarted(int gdbServerPort, int qmlPort)
|
||||
void AndroidDebugSupport::handleRemoteProcessStarted(Utils::Port gdbServerPort, Utils::Port qmlPort)
|
||||
{
|
||||
disconnect(m_runner, &AndroidRunner::remoteProcessStarted,
|
||||
this, &AndroidDebugSupport::handleRemoteProcessStarted);
|
||||
|
||||
@@ -49,7 +49,7 @@ public:
|
||||
QString *errorMessage);
|
||||
|
||||
private:
|
||||
void handleRemoteProcessStarted(int gdbServerPort, int qmlPort);
|
||||
void handleRemoteProcessStarted(Utils::Port gdbServerPort, Utils::Port qmlPort);
|
||||
|
||||
Debugger::DebuggerRunControl *m_runControl;
|
||||
AndroidRunner * const m_runner;
|
||||
|
||||
@@ -137,16 +137,16 @@ AndroidRunner::AndroidRunner(QObject *parent,
|
||||
m_qmlDebugServices = QmlDebug::NoQmlDebugServices;
|
||||
QString channel = runConfig->remoteChannel();
|
||||
QTC_CHECK(channel.startsWith(QLatin1Char(':')));
|
||||
m_localGdbServerPort = channel.mid(1).toUShort();
|
||||
QTC_CHECK(m_localGdbServerPort);
|
||||
m_localGdbServerPort = Utils::Port(channel.mid(1).toUShort());
|
||||
QTC_CHECK(m_localGdbServerPort.isValid());
|
||||
if (m_qmlDebugServices != QmlDebug::NoQmlDebugServices) {
|
||||
QTcpServer server;
|
||||
QTC_ASSERT(server.listen(QHostAddress::LocalHost)
|
||||
|| server.listen(QHostAddress::LocalHostIPv6),
|
||||
qDebug() << tr("No free ports available on host for QML debugging."));
|
||||
m_qmlPort = server.serverPort();
|
||||
m_qmlPort = Utils::Port(server.serverPort());
|
||||
} else {
|
||||
m_qmlPort = 0;
|
||||
m_qmlPort = Utils::Port();
|
||||
}
|
||||
ProjectExplorer::Target *target = runConfig->target();
|
||||
m_androidRunnable.intentName = AndroidManager::intentName(target);
|
||||
@@ -276,18 +276,18 @@ void AndroidRunner::checkPID()
|
||||
if (m_useCppDebugger) {
|
||||
// This will be funneled to the engine to actually start and attach
|
||||
// gdb. Afterwards this ends up in handleRemoteDebuggerRunning() below.
|
||||
QByteArray serverChannel = ':' + QByteArray::number(m_localGdbServerPort);
|
||||
QByteArray serverChannel = ':' + QByteArray::number(m_localGdbServerPort.number());
|
||||
emit remoteServerRunning(serverChannel, m_processPID);
|
||||
} else if (m_qmlDebugServices == QmlDebug::QmlDebuggerServices) {
|
||||
// This will be funneled to the engine to actually start and attach
|
||||
// gdb. Afterwards this ends up in handleRemoteDebuggerRunning() below.
|
||||
QByteArray serverChannel = QByteArray::number(m_qmlPort);
|
||||
QByteArray serverChannel = QByteArray::number(m_qmlPort.number());
|
||||
emit remoteServerRunning(serverChannel, m_processPID);
|
||||
} else if (m_qmlDebugServices == QmlDebug::QmlProfilerServices) {
|
||||
emit remoteProcessStarted(-1, m_qmlPort);
|
||||
emit remoteProcessStarted(Utils::Port(), m_qmlPort);
|
||||
} else {
|
||||
// Start without debugging.
|
||||
emit remoteProcessStarted(-1, -1);
|
||||
emit remoteProcessStarted(Utils::Port(), Utils::Port());
|
||||
}
|
||||
m_wasStarted = true;
|
||||
logcatReadStandardOutput();
|
||||
@@ -348,7 +348,7 @@ void AndroidRunner::asyncStart()
|
||||
if (m_useCppDebugger) {
|
||||
QProcess adb;
|
||||
adb.start(m_adb, selector() << _("forward")
|
||||
<< QString::fromLatin1("tcp:%1").arg(m_localGdbServerPort)
|
||||
<< QString::fromLatin1("tcp:%1").arg(m_localGdbServerPort.number())
|
||||
<< _("localfilesystem:") + m_gdbserverSocket);
|
||||
if (!adb.waitForStarted()) {
|
||||
emit remoteProcessFinished(tr("Failed to forward C++ debugging ports. Reason: %1.").arg(adb.errorString()));
|
||||
@@ -390,7 +390,7 @@ void AndroidRunner::asyncStart()
|
||||
|
||||
if (m_qmlDebugServices != QmlDebug::NoQmlDebugServices) {
|
||||
// currently forward to same port on device and host
|
||||
const QString port = QString::fromLatin1("tcp:%1").arg(m_qmlPort);
|
||||
const QString port = QString::fromLatin1("tcp:%1").arg(m_qmlPort.number());
|
||||
QProcess adb;
|
||||
adb.start(m_adb, selector() << _("forward") << port << port);
|
||||
if (!adb.waitForStarted()) {
|
||||
@@ -405,7 +405,7 @@ void AndroidRunner::asyncStart()
|
||||
args << _("-e") << _("qml_debug") << _("true")
|
||||
<< _("-e") << _("qmljsdebugger")
|
||||
<< QString::fromLatin1("port:%1,block,services:%2")
|
||||
.arg(m_qmlPort).arg(QmlDebug::qmlDebugServices(m_qmlDebugServices));
|
||||
.arg(m_qmlPort.number()).arg(QmlDebug::qmlDebugServices(m_qmlDebugServices));
|
||||
}
|
||||
|
||||
QProcess adb;
|
||||
|
||||
@@ -68,7 +68,7 @@ public slots:
|
||||
|
||||
signals:
|
||||
void remoteServerRunning(const QByteArray &serverChannel, int pid);
|
||||
void remoteProcessStarted(int gdbServerPort, int qmlPort);
|
||||
void remoteProcessStarted(Utils::Port gdbServerPort, Utils::Port qmlPort);
|
||||
void remoteProcessFinished(const QString &errString = QString());
|
||||
|
||||
void remoteOutput(const QString &output);
|
||||
@@ -101,8 +101,8 @@ private:
|
||||
qint64 m_processPID;
|
||||
bool m_useCppDebugger;
|
||||
QmlDebug::QmlDebugServicesPreset m_qmlDebugServices;
|
||||
ushort m_localGdbServerPort; // Local end of forwarded debug socket.
|
||||
quint16 m_qmlPort;
|
||||
Utils::Port m_localGdbServerPort; // Local end of forwarded debug socket.
|
||||
Utils::Port m_qmlPort;
|
||||
QString m_pingFile;
|
||||
QString m_pongFile;
|
||||
QString m_gdbserverPath;
|
||||
|
||||
Reference in New Issue
Block a user