aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/plugins/qmltooling/qmldbg_tcp/qtcpserverconnection.cpp30
-rw-r--r--src/plugins/qmltooling/qmldbg_tcp/qtcpserverconnection.h2
-rw-r--r--src/qml/debugger/qqmldebugserver.cpp37
-rw-r--r--src/qml/debugger/qqmldebugserverconnection_p.h2
4 files changed, 50 insertions, 21 deletions
diff --git a/src/plugins/qmltooling/qmldbg_tcp/qtcpserverconnection.cpp b/src/plugins/qmltooling/qmldbg_tcp/qtcpserverconnection.cpp
index fbdb201b04..86e1a70841 100644
--- a/src/plugins/qmltooling/qmldbg_tcp/qtcpserverconnection.cpp
+++ b/src/plugins/qmltooling/qmldbg_tcp/qtcpserverconnection.cpp
@@ -54,7 +54,8 @@ class QTcpServerConnectionPrivate {
public:
QTcpServerConnectionPrivate();
- int port;
+ int portFrom;
+ int portTo;
bool block;
QString hostaddress;
QTcpSocket *socket;
@@ -65,7 +66,8 @@ public:
};
QTcpServerConnectionPrivate::QTcpServerConnectionPrivate() :
- port(0),
+ portFrom(0),
+ portTo(0),
block(false),
socket(0),
protocol(0),
@@ -135,10 +137,12 @@ bool QTcpServerConnection::waitForMessage()
return d->protocol->waitForReadyRead(-1);
}
-void QTcpServerConnection::setPort(int port, bool block, const QString &hostaddress)
+void QTcpServerConnection::setPortRange(int portFrom, int portTo, bool block,
+ const QString &hostaddress)
{
Q_D(QTcpServerConnection);
- d->port = port;
+ d->portFrom = portFrom;
+ d->portTo = portTo;
d->block = block;
d->hostaddress = hostaddress;
@@ -163,10 +167,20 @@ void QTcpServerConnection::listen()
} else {
hostaddress = QHostAddress::Any;
}
- if (d->tcpServer->listen(hostaddress, d->port))
- qDebug("QML Debugger: Waiting for connection on port %d...", d->port);
- else
- qWarning("QML Debugger: Unable to listen to port %d.", d->port);
+ int port = d->portFrom;
+ do {
+ if (d->tcpServer->listen(hostaddress, port)) {
+ qDebug("QML Debugger: Waiting for connection on port %d...", port);
+ break;
+ }
+ ++port;
+ } while (port <= d->portTo);
+ if (port > d->portTo) {
+ if (d->portFrom == d->portTo)
+ qWarning("QML Debugger: Unable to listen to port %d.", d->portFrom);
+ else
+ qWarning("QML Debugger: Unable to listen to ports %d - %d.", d->portFrom, d->portTo);
+ }
}
diff --git a/src/plugins/qmltooling/qmldbg_tcp/qtcpserverconnection.h b/src/plugins/qmltooling/qmldbg_tcp/qtcpserverconnection.h
index 33157906c8..525ed50e51 100644
--- a/src/plugins/qmltooling/qmldbg_tcp/qtcpserverconnection.h
+++ b/src/plugins/qmltooling/qmldbg_tcp/qtcpserverconnection.h
@@ -61,7 +61,7 @@ public:
~QTcpServerConnection();
void setServer(QQmlDebugServer *server);
- void setPort(int port, bool bock, const QString &hostaddress);
+ void setPortRange(int portFrom, int portTo, bool bock, const QString &hostaddress);
bool isConnected() const;
void send(const QList<QByteArray> &messages);
diff --git a/src/qml/debugger/qqmldebugserver.cpp b/src/qml/debugger/qqmldebugserver.cpp
index 7c9928c43c..27e3d226cd 100644
--- a/src/qml/debugger/qqmldebugserver.cpp
+++ b/src/qml/debugger/qqmldebugserver.cpp
@@ -123,8 +123,9 @@ public:
m_pluginName = pluginName;
}
- void setPort(int port, bool block, QString &hostAddress) {
- m_port = port;
+ void setPortRange(int portFrom, int portTo, bool block, QString &hostAddress) {
+ m_portFrom = portFrom;
+ m_portTo = portTo;
m_block = block;
m_hostAddress = hostAddress;
}
@@ -133,7 +134,8 @@ public:
private:
QString m_pluginName;
- int m_port;
+ int m_portFrom;
+ int m_portTo;
bool m_block;
QString m_hostAddress;
};
@@ -225,7 +227,7 @@ void QQmlDebugServerThread::run()
= server->d_func()->loadConnectionPlugin(m_pluginName);
if (connection) {
connection->setServer(QQmlDebugServer::instance());
- connection->setPort(m_port, m_block, m_hostAddress);
+ connection->setPortRange(m_portFrom, m_portTo, m_block, m_hostAddress);
} else {
QCoreApplicationPrivate *appD = static_cast<QCoreApplicationPrivate*>(QObjectPrivate::get(qApp));
qWarning() << QString(QLatin1String("QML Debugger: Ignoring \"-qmljsdebugger=%1\". "
@@ -272,12 +274,13 @@ QQmlDebugServer *QQmlDebugServer::instance()
QCoreApplicationPrivate *appD = static_cast<QCoreApplicationPrivate*>(QObjectPrivate::get(qApp));
#ifndef QT_QML_NO_DEBUGGER
// ### remove port definition when protocol is changed
- int port = 0;
+ int portFrom = 0;
+ int portTo = 0;
bool block = false;
bool ok = false;
QString hostAddress;
- // format: qmljsdebugger=port:3768[,host:<ip address>][,block] OR qmljsdebugger=ost[,block]
+ // format: qmljsdebugger=port:<port_from>[,port_to],host:<ip address>][,block]
if (!appD->qmljsDebugArgumentsString().isEmpty()) {
if (!QQmlEnginePrivate::qml_debugging_enabled) {
qWarning() << QString(QLatin1String(
@@ -290,9 +293,21 @@ QQmlDebugServer *QQmlDebugServer::instance()
QString pluginName;
QStringList lstjsDebugArguments = appD->qmljsDebugArgumentsString()
.split(QLatin1Char(','));
- foreach (const QString &strArgument, lstjsDebugArguments) {
+ QStringList::const_iterator argsItEnd = lstjsDebugArguments.end();
+ QStringList::const_iterator argsIt = lstjsDebugArguments.begin();
+ for (; argsIt != argsItEnd; ++argsIt) {
+ const QString strArgument = *argsIt;
if (strArgument.startsWith(QLatin1String("port:"))) {
- port = strArgument.mid(5).toInt(&ok);
+ portFrom = strArgument.mid(5).toInt(&ok);
+ portTo = portFrom;
+ QStringList::const_iterator argsNext = argsIt + 1;
+ if (argsNext == argsItEnd)
+ break;
+ const QString nextArgument = *argsNext;
+ if (ok && nextArgument.contains(QRegExp(QStringLiteral("^\\s*\\d+\\s*$")))) {
+ portTo = nextArgument.toInt(&ok);
+ ++argsIt;
+ }
pluginName = QLatin1String("qmldbg_tcp");
} else if (strArgument.startsWith(QLatin1String("host:"))) {
hostAddress = strArgument.mid(5);
@@ -311,7 +326,7 @@ QQmlDebugServer *QQmlDebugServer::instance()
qQmlDebugServer->d_func()->thread = thread;
qQmlDebugServer->moveToThread(thread);
thread->setPluginName(pluginName);
- thread->setPort(port, block, hostAddress);
+ thread->setPortRange(portFrom, portTo, block, hostAddress);
QQmlDebugServerPrivate *d = qQmlDebugServer->d_func();
d->blockingMode = block;
@@ -325,8 +340,8 @@ QQmlDebugServer *QQmlDebugServer::instance()
} else {
qWarning() << QString(QLatin1String(
"QML Debugger: Ignoring \"-qmljsdebugger=%1\". "
- "Format is -qmljsdebugger=port:<port>[,block]")).arg(
- appD->qmljsDebugArgumentsString());
+ "Format is qmljsdebugger=port:<port_from>[,port_to],host:"
+ "<ip address>][,block]")).arg(appD->qmljsDebugArgumentsString());
}
}
#else
diff --git a/src/qml/debugger/qqmldebugserverconnection_p.h b/src/qml/debugger/qqmldebugserverconnection_p.h
index 82a02bb29e..a7c35c2d2f 100644
--- a/src/qml/debugger/qqmldebugserverconnection_p.h
+++ b/src/qml/debugger/qqmldebugserverconnection_p.h
@@ -67,7 +67,7 @@ public:
virtual ~QQmlDebugServerConnection() {}
virtual void setServer(QQmlDebugServer *server) = 0;
- virtual void setPort(int port, bool bock, const QString &hostaddress) = 0;
+ virtual void setPortRange(int portFrom, int portTo, bool bock, const QString &hostaddress) = 0;
virtual bool isConnected() const = 0;
virtual void send(const QList<QByteArray> &messages) = 0;
virtual void disconnect() = 0;