summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLasse Holmstedt <lasse.holmstedt@nokia.com>2010-09-17 08:13:51 (GMT)
committerKai Koehne <kai.koehne@nokia.com>2010-09-17 13:51:18 (GMT)
commita9e5329168cd9113bf41293c05193d8b099494c6 (patch)
treedaaf47e37ff0343596cc3c2e67afe25251be8b32
parent2046037499830506ec24097c9b7a739bb7c78566 (diff)
downloadQt-a9e5329168cd9113bf41293c05193d8b099494c6.zip
Qt-a9e5329168cd9113bf41293c05193d8b099494c6.tar.gz
Qt-a9e5329168cd9113bf41293c05193d8b099494c6.tar.bz2
Make qml debugging work with command line arguments
The environment variables do not work for Symbian devices, so without this change, QML debugging cannot be done on them. In addition, configure now contains an option to disable qml debugging entirely, due to it being a major security risk. Reviewed-by: kkoehne
-rwxr-xr-xconfigure24
-rwxr-xr-xconfigure.exebin1321472 -> 1402368 bytes
-rw-r--r--src/corelib/kernel/qcoreapplication.cpp3
-rw-r--r--src/declarative/debugger/qdeclarativedebugservice.cpp41
-rw-r--r--src/gui/kernel/qapplication.cpp6
-rw-r--r--src/gui/kernel/qapplication_p.h2
-rw-r--r--tests/auto/declarative/qdeclarativedebug/tst_qdeclarativedebug.cpp16
-rw-r--r--tests/auto/declarative/qdeclarativedebugclient/tst_qdeclarativedebugclient.cpp15
-rw-r--r--tests/auto/declarative/qdeclarativedebugservice/tst_qdeclarativedebugservice.cpp16
-rw-r--r--tools/configure/configureapp.cpp11
10 files changed, 114 insertions, 20 deletions
diff --git a/configure b/configure
index 1ad0181..144bfbd 100755
--- a/configure
+++ b/configure
@@ -685,6 +685,7 @@ CFG_MULTIMEDIA=auto
CFG_AUDIO_BACKEND=auto
CFG_SVG=auto
CFG_DECLARATIVE=auto
+CFG_DECLARATIVE_DEBUG=yes
CFG_WEBKIT=auto # (yes|no|auto)
CFG_JAVASCRIPTCORE_JIT=auto
@@ -1997,6 +1998,17 @@ while [ "$#" -gt 0 ]; do
fi
fi
;;
+ declarative-debug)
+ if [ "$VAL" = "yes" ]; then
+ CFG_DECLARATIVE_DEBUG="yes"
+ else
+ if [ "$VAL" = "no" ]; then
+ CFG_DECLARATIVE_DEBUG="no"
+ else
+ UNKNOWN_OPT=yes
+ fi
+ fi
+ ;;
webkit)
if [ "$VAL" = "yes" ] || [ "$VAL" = "auto" ]; then
CFG_WEBKIT="yes"
@@ -3524,7 +3536,8 @@ Usage: $relconf [-h] [-prefix <dir>] [-prefix-install] [-bindir <dir>] [-libdir
[-no-media-backend] [-media-backend] [-no-audio-backend] [-audio-backend]
[-no-openssl] [-openssl] [-openssl-linked]
[-no-gtkstyle] [-gtkstyle] [-no-svg] [-svg] [-no-webkit] [-webkit] [-no-javascript-jit] [-javascript-jit]
- [-no-script] [-script] [-no-scripttools] [-scripttools] [-no-declarative] [-declarative]
+ [-no-script] [-script] [-no-scripttools] [-scripttools]
+ [-no-declarative] [-declarative][-no-declarative-debug] [-declarative-debug]
[additional platform specific options (see below)]
@@ -3687,9 +3700,12 @@ fi
-no-scripttools .... Do not build the QtScriptTools module.
+ -scripttools ....... Build the QtScriptTools module.
- -no-declarative .....Do not build the declarative module.
+ -no-declarative ..... Do not build the declarative module.
+ -declarative ....... Build the declarative module.
+ -no-declarative-debug ..... Do not build the declarative debugging support.
+ + -declarative-debug ....... Build the declarative debugging support.
+
-platform target ... The operating system and compiler you are building
on ($PLATFORM).
@@ -7229,6 +7245,9 @@ fi
if [ "$CFG_DECLARATIVE" = "yes" ]; then
QT_CONFIG="$QT_CONFIG declarative"
+ if [ "$CFG_DECLARATIVE_DEBUG" = "no" ]; then
+ QCONFIG_FLAGS="$QCONFIG_FLAGS QDECLARATIVE_NO_DEBUG_PROTOCOL"
+ fi
else
QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_DECLARATIVE"
fi
@@ -8197,6 +8216,7 @@ if [ "$CFG_WEBKIT" = "yes" ]; then
fi
fi
echo "Declarative module ..... $CFG_DECLARATIVE"
+echo "Declarative debugging ...$CFG_DECLARATIVE_DEBUG"
echo "Support for S60 ........ $CFG_S60"
echo "Symbian DEF files ...... $CFG_SYMBIAN_DEFFILES"
echo "STL support ............ $CFG_STL"
diff --git a/configure.exe b/configure.exe
index 18c9004..e2f4331 100755
--- a/configure.exe
+++ b/configure.exe
Binary files differ
diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp
index 512e193..d3f399b 100644
--- a/src/corelib/kernel/qcoreapplication.cpp
+++ b/src/corelib/kernel/qcoreapplication.cpp
@@ -2091,7 +2091,8 @@ QStringList QCoreApplication::arguments()
l1arg == "-stylesheet" ||
l1arg == "-widgetcount")
;
- else if (l1arg.startsWith("-style="))
+ else if (l1arg.startsWith("-style=") ||
+ l1arg.startsWith("-qmljsdebugger="))
;
else if (l1arg == "-style" ||
l1arg == "-session" ||
diff --git a/src/declarative/debugger/qdeclarativedebugservice.cpp b/src/declarative/debugger/qdeclarativedebugservice.cpp
index 1bbfcf4..1f2bf4f 100644
--- a/src/declarative/debugger/qdeclarativedebugservice.cpp
+++ b/src/declarative/debugger/qdeclarativedebugservice.cpp
@@ -49,6 +49,8 @@
#include <QtCore/qstringlist.h>
#include <private/qobject_p.h>
+#include <private/qapplication_p.h>
+#include <QtGui/qapplication.h>
QT_BEGIN_NAMESPACE
@@ -147,24 +149,41 @@ bool QDeclarativeDebugServer::hasDebuggingClient() const
QDeclarativeDebugServer *QDeclarativeDebugServer::instance()
{
- static bool envTested = false;
+ static bool commandLineTested = false;
static QDeclarativeDebugServer *server = 0;
- if (!envTested) {
- envTested = true;
- QByteArray env = qgetenv("QML_DEBUG_SERVER_PORT");
- QByteArray block = qgetenv("QML_DEBUG_SERVER_BLOCK");
+ if (!commandLineTested) {
+ commandLineTested = true;
+#ifndef QDECLARATIVE_NO_DEBUG_PROTOCOL
+ QApplicationPrivate *appD = static_cast<QApplicationPrivate*>(QObjectPrivate::get(qApp));
+ // ### remove port definition when protocol is changed
+ int port = 0;
+ bool block = false;
bool ok = false;
- int port = env.toInt(&ok);
- if (ok && port > 1024) {
- server = new QDeclarativeDebugServer(port);
- server->listen();
- if (!block.isEmpty()) {
- server->waitForConnection();
+ // format: qmljsdebugger=port:3768[,block]
+ if (!appD->qmljsDebugArguments.isEmpty()) {
+
+ if (appD->qmljsDebugArguments.indexOf(QLatin1String("port:")) == 0) {
+ int separatorIndex = appD->qmljsDebugArguments.indexOf(QLatin1Char(','));
+ port = appD->qmljsDebugArguments.mid(5, separatorIndex - 5).toInt(&ok);
+ }
+ block = appD->qmljsDebugArguments.contains(QLatin1String("block"));
+
+ if (ok) {
+ server = new QDeclarativeDebugServer(port);
+ server->listen();
+ if (block) {
+ server->waitForConnection();
+ }
+ } else {
+ qWarning(QString("QDeclarativeDebugServer: Ignoring \"-qmljsdebugger=%1\". "
+ "Format is -qmljsdebugger=port:<port>[,block]").arg(
+ appD->qmljsDebugArguments).toAscii().constData());
}
}
+#endif
}
return server;
diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp
index 2fd2f46..43d5772 100644
--- a/src/gui/kernel/qapplication.cpp
+++ b/src/gui/kernel/qapplication.cpp
@@ -494,6 +494,7 @@ bool QApplicationPrivate::fade_tooltip = false;
bool QApplicationPrivate::animate_toolbox = false;
bool QApplicationPrivate::widgetCount = false;
bool QApplicationPrivate::load_testability = false;
+QString QApplicationPrivate::qmljsDebugArguments;
#ifdef QT_KEYPAD_NAVIGATION
# ifdef Q_OS_SYMBIAN
Qt::NavigationMode QApplicationPrivate::navigationMode = Qt::NavigationModeKeypadDirectional;
@@ -565,6 +566,8 @@ void QApplicationPrivate::process_cmdline()
QString s;
if (arg == "-qdevel" || arg == "-qdebug") {
// obsolete argument
+ } else if (arg.indexOf("-qmljsdebugger=", 0) != -1) {
+ qmljsDebugArguments = QString::fromLocal8Bit(arg.right(arg.length() - 15));
} else if (arg.indexOf("-style=", 0) != -1) {
s = QString::fromLocal8Bit(arg.right(arg.length() - 7).toLower());
} else if (arg == "-style" && i < argc-1) {
@@ -670,6 +673,9 @@ void QApplicationPrivate::process_cmdline()
Qt::RightToLeft
\o -graphicssystem, sets the backend to be used for on-screen widgets
and QPixmaps. Available options are \c{raster} and \c{opengl}.
+ \o -qmljsdebugger=, activates the QML/JS debugger with a specified port.
+ The value must be of format port:1234[,block], where block is optional
+ and will make the application wait until a debugger connects to it.
\endlist
The X11 version of Qt supports some traditional X11 command line options:
diff --git a/src/gui/kernel/qapplication_p.h b/src/gui/kernel/qapplication_p.h
index 8dc16e0..aa3a6d5 100644
--- a/src/gui/kernel/qapplication_p.h
+++ b/src/gui/kernel/qapplication_p.h
@@ -446,6 +446,8 @@ public:
static bool animate_toolbox;
static bool widgetCount; // Coupled with -widgetcount switch
static bool load_testability; // Coupled with -testability switch
+ static QString qmljsDebugArguments; // a string containing arguments for js/qml debugging.
+
#ifdef Q_WS_MAC
static bool native_modal_dialog_active;
#endif
diff --git a/tests/auto/declarative/qdeclarativedebug/tst_qdeclarativedebug.cpp b/tests/auto/declarative/qdeclarativedebug/tst_qdeclarativedebug.cpp
index 20ccccb..adba190 100644
--- a/tests/auto/declarative/qdeclarativedebug/tst_qdeclarativedebug.cpp
+++ b/tests/auto/declarative/qdeclarativedebug/tst_qdeclarativedebug.cpp
@@ -279,7 +279,7 @@ void tst_QDeclarativeDebug::initTestCase()
qRegisterMetaType<QDeclarativeDebugWatch::State>();
QTest::ignoreMessage(QtWarningMsg, "QDeclarativeDebugServer: Waiting for connection on port 3768...");
- qputenv("QML_DEBUG_SERVER_PORT", "3768");
+
m_engine = new QDeclarativeEngine(this);
QList<QByteArray> qml;
@@ -891,6 +891,18 @@ void tst_QDeclarativeDebug::tst_QDeclarativeDebugPropertyReference()
compareProperties(r, ref);
}
-QTEST_MAIN(tst_QDeclarativeDebug)
+int main(int argc, char *argv[])
+{
+ int _argc = argc + 1;
+ char **_argv = new char*[_argc];
+ for (int i = 0; i < argc; ++i)
+ _argv[i] = argv[i];
+ _argv[_argc - 1] = "-qmljsdebugger=port:3768";
+
+ QApplication app(_argc, _argv);
+ tst_QDeclarativeDebug tc;
+ return QTest::qExec(&tc, _argc, _argv);
+ delete _argv;
+}
#include "tst_qdeclarativedebug.moc"
diff --git a/tests/auto/declarative/qdeclarativedebugclient/tst_qdeclarativedebugclient.cpp b/tests/auto/declarative/qdeclarativedebugclient/tst_qdeclarativedebugclient.cpp
index a19c2c2..7db0e60 100644
--- a/tests/auto/declarative/qdeclarativedebugclient/tst_qdeclarativedebugclient.cpp
+++ b/tests/auto/declarative/qdeclarativedebugclient/tst_qdeclarativedebugclient.cpp
@@ -76,7 +76,6 @@ void tst_QDeclarativeDebugClient::initTestCase()
{
QTest::ignoreMessage(QtWarningMsg, "QDeclarativeDebugServer: Waiting for connection on port 3770...");
- qputenv("QML_DEBUG_SERVER_PORT", "3770");
new QDeclarativeEngine(this);
m_conn = new QDeclarativeDebugConnection(this);
@@ -151,7 +150,19 @@ void tst_QDeclarativeDebugClient::sendMessage()
QCOMPARE(resp, msg);
}
-QTEST_MAIN(tst_QDeclarativeDebugClient)
+int main(int argc, char *argv[])
+{
+ int _argc = argc + 1;
+ char **_argv = new char*[_argc];
+ for (int i = 0; i < argc; ++i)
+ _argv[i] = argv[i];
+ _argv[_argc - 1] = "-qmljsdebugger=port:3770";
+
+ QApplication app(_argc, _argv);
+ tst_QDeclarativeDebugClient tc;
+ return QTest::qExec(&tc, _argc, _argv);
+ delete _argv;
+}
#include "tst_qdeclarativedebugclient.moc"
diff --git a/tests/auto/declarative/qdeclarativedebugservice/tst_qdeclarativedebugservice.cpp b/tests/auto/declarative/qdeclarativedebugservice/tst_qdeclarativedebugservice.cpp
index 9ebbbaf..4683199 100644
--- a/tests/auto/declarative/qdeclarativedebugservice/tst_qdeclarativedebugservice.cpp
+++ b/tests/auto/declarative/qdeclarativedebugservice/tst_qdeclarativedebugservice.cpp
@@ -77,7 +77,6 @@ private slots:
void tst_QDeclarativeDebugService::initTestCase()
{
QTest::ignoreMessage(QtWarningMsg, "QDeclarativeDebugServer: Waiting for connection on port 3769...");
- qputenv("QML_DEBUG_SERVER_PORT", "3769");
new QDeclarativeEngine(this);
m_conn = new QDeclarativeDebugConnection(this);
@@ -184,6 +183,19 @@ void tst_QDeclarativeDebugService::objectToString()
delete obj;
}
-QTEST_MAIN(tst_QDeclarativeDebugService)
+
+int main(int argc, char *argv[])
+{
+ int _argc = argc + 1;
+ char **_argv = new char*[_argc];
+ for (int i = 0; i < argc; ++i)
+ _argv[i] = argv[i];
+ _argv[_argc - 1] = "-qmljsdebugger=port:3769";
+
+ QApplication app(_argc, _argv);
+ tst_QDeclarativeDebugService tc;
+ return QTest::qExec(&tc, _argc, _argv);
+ delete _argv;
+}
#include "tst_qdeclarativedebugservice.moc"
diff --git a/tools/configure/configureapp.cpp b/tools/configure/configureapp.cpp
index 6e66742..a2c7fe9 100644
--- a/tools/configure/configureapp.cpp
+++ b/tools/configure/configureapp.cpp
@@ -279,6 +279,7 @@ Configure::Configure(int& argc, char** argv)
dictionary[ "DIRECTSHOW" ] = "no";
dictionary[ "WEBKIT" ] = "auto";
dictionary[ "DECLARATIVE" ] = "auto";
+ dictionary[ "DECLARATIVE_DEBUG" ]= "yes";
dictionary[ "PLUGIN_MANIFESTS" ] = "yes";
QString version;
@@ -961,6 +962,10 @@ void Configure::parseCmdLine()
dictionary[ "DECLARATIVE" ] = "no";
} else if (configCmdLine.at(i) == "-declarative") {
dictionary[ "DECLARATIVE" ] = "yes";
+ } else if (configCmdLine.at(i) == "-no-declarative-debug") {
+ dictionary[ "DECLARATIVE_DEBUG" ] = "no";
+ } else if (configCmdLine.at(i) == "-declarative-debug") {
+ dictionary[ "DECLARATIVE_DEBUG" ] = "yes";
} else if (configCmdLine.at(i) == "-no-plugin-manifests") {
dictionary[ "PLUGIN_MANIFESTS" ] = "no";
} else if (configCmdLine.at(i) == "-plugin-manifests") {
@@ -1836,6 +1841,8 @@ bool Configure::displayHelp()
desc("SCRIPTTOOLS", "yes", "-scripttools", "Build the QtScriptTools module.");
desc("DECLARATIVE", "no", "-no-declarative", "Do not build the declarative module");
desc("DECLARATIVE", "yes", "-declarative", "Build the declarative module");
+ desc("DECLARATIVE_DEBUG", "no", "-no-declarative-debug", "Do not build the declarative debugging support");
+ desc("DECLARATIVE_DEBUG", "yes", "-declarative-debug", "Build the declarative debugging support");
desc( "-arch <arch>", "Specify an architecture.\n"
"Available values for <arch>:");
@@ -2273,6 +2280,8 @@ void Configure::autoDetection()
dictionary["WEBKIT"] = checkAvailability("WEBKIT") ? "yes" : "no";
if (dictionary["DECLARATIVE"] == "auto")
dictionary["DECLARATIVE"] = dictionary["SCRIPT"] == "yes" ? "yes" : "no";
+ if (dictionary["DECLARATIVE_DEBUG"] == "auto")
+ dictionary["DECLARATIVE_DEBUG"] = dictionary["DECLARATIVE"] == "yes" ? "yes" : "no";
if (dictionary["AUDIO_BACKEND"] == "auto")
dictionary["AUDIO_BACKEND"] = checkAvailability("AUDIO_BACKEND") ? "yes" : "no";
if (dictionary["WMSDK"] == "auto")
@@ -3101,6 +3110,7 @@ void Configure::generateConfigfiles()
if (dictionary["IPV6"] == "no") qconfigList += "QT_NO_IPV6";
if (dictionary["WEBKIT"] == "no") qconfigList += "QT_NO_WEBKIT";
if (dictionary["DECLARATIVE"] == "no") qconfigList += "QT_NO_DECLARATIVE";
+ if (dictionary["DECLARATIVE_DEBUG"] == "no") qconfigList += "QDECLARATIVE_NO_DEBUG_PROTOCOL";
if (dictionary["PHONON"] == "no") qconfigList += "QT_NO_PHONON";
if (dictionary["MULTIMEDIA"] == "no") qconfigList += "QT_NO_MULTIMEDIA";
if (dictionary["XMLPATTERNS"] == "no") qconfigList += "QT_NO_XMLPATTERNS";
@@ -3398,6 +3408,7 @@ void Configure::displayConfig()
cout << "QtMultimedia support........" << dictionary[ "MULTIMEDIA" ] << endl;
cout << "WebKit support.............." << dictionary[ "WEBKIT" ] << endl;
cout << "Declarative support........." << dictionary[ "DECLARATIVE" ] << endl;
+ cout << "Declarative debugging......." << dictionary[ "DECLARATIVE_DEBUG" ] << endl;
cout << "QtScript support............" << dictionary[ "SCRIPT" ] << endl;
cout << "QtScriptTools support......." << dictionary[ "SCRIPTTOOLS" ] << endl;
cout << "Graphics System............." << dictionary[ "GRAPHICS_SYSTEM" ] << endl;