aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/debugger
diff options
context:
space:
mode:
authorAurindam Jana <aurindam.jana@digia.com>2013-03-18 17:17:52 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-04-02 13:26:03 +0200
commitf15595901b645fc3c168ef18f81ae4617b439e92 (patch)
treeedcb11ea4a7ee984a0e66b1b1f94fbdf1b08dd2f /src/qml/debugger
parent3e0bcbff98346385ec32bc951cd958d1c1bfb371 (diff)
Debugger: Accepts port range as arguments
Allow a port range to pass on command line, and try to listen on any of the ports in the range. (Re)using the ',' separator allows for backwards compatibility, that is, also Qt 4 will accept a -qmljsdebugger=port:1000,1010 argument, but will only try to listen on port 1000. Change-Id: Ic03fe20e4aee9ecdea86651f46f1df5cb19bd75c Reviewed-by: Kai Koehne <kai.koehne@digia.com>
Diffstat (limited to 'src/qml/debugger')
-rw-r--r--src/qml/debugger/qqmldebugserver.cpp37
-rw-r--r--src/qml/debugger/qqmldebugserverconnection_p.h2
2 files changed, 27 insertions, 12 deletions
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;