summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRafael Roquetto <rafael.roquetto.qnx@kdab.com>2012-03-26 18:55:58 (GMT)
committerQt by Nokia <qt-info@nokia.com>2012-04-20 16:32:24 (GMT)
commit8599a0e6397391634ee52197e164f6b7121f9a4d (patch)
tree16a88bbe99f83ec30358e107cfb20004a395ed19 /src
parent2e897ab99413bb1e4fd3f057f431785e3ac7abb0 (diff)
downloadQt-8599a0e6397391634ee52197e164f6b7121f9a4d.zip
Qt-8599a0e6397391634ee52197e164f6b7121f9a4d.tar.gz
Qt-8599a0e6397391634ee52197e164f6b7121f9a4d.tar.bz2
Moved qmljs_debug_arguments to QCoreApplication
Enable the use of the QML debugger without QtGUI Based on Qt5's 9a096d9e. Change-Id: If97502bc5367e0faadfaf3bbe70b0c89ef2c75c2 Reviewed-by: Kai Koehne <kai.koehne@nokia.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src')
-rw-r--r--src/corelib/kernel/qcoreapplication.cpp31
-rw-r--r--src/corelib/kernel/qcoreapplication_p.h3
-rw-r--r--src/declarative/debugger/qdeclarativedebugserver.cpp26
-rw-r--r--src/gui/kernel/qapplication.cpp8
-rw-r--r--src/gui/kernel/qapplication_p.h2
5 files changed, 47 insertions, 23 deletions
diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp
index bee95eb..2654a6c 100644
--- a/src/corelib/kernel/qcoreapplication.cpp
+++ b/src/corelib/kernel/qcoreapplication.cpp
@@ -217,6 +217,30 @@ bool QCoreApplicationPrivate::checkInstance(const char *function)
return b;
}
+Q_GLOBAL_STATIC(QString, qmljs_debug_arguments);
+
+void QCoreApplicationPrivate::processCommandLineArguments()
+{
+ int j = argc ? 1 : 0;
+ for (int i = 1; i < argc; ++i) {
+ if (argv[i] && *argv[i] != '-') {
+ argv[j++] = argv[i];
+ continue;
+ }
+ QByteArray arg = argv[i];
+ if (arg.startsWith("-qmljsdebugger=")) {
+ *qmljs_debug_arguments() = QString::fromLocal8Bit(arg.right(arg.length() - 15));
+ } else {
+ argv[j++] = argv[i];
+ }
+ }
+
+ if (j < argc) {
+ argv[j] = 0;
+ argc = j;
+ }
+}
+
// Support for introspection
QSignalSpyCallbackSet Q_CORE_EXPORT qt_signal_spy_callback_set = { 0, 0, 0, 0 };
@@ -497,6 +521,11 @@ void QCoreApplicationPrivate::appendApplicationPathToLibraryPaths()
#endif
}
+QString QCoreApplicationPrivate::qmljsDebugArguments()
+{
+ return *qmljs_debug_arguments();
+}
+
QString qAppName()
{
if (!QCoreApplicationPrivate::checkInstance("qAppName"))
@@ -742,6 +771,8 @@ void QCoreApplication::init()
}
#endif
+ d->processCommandLineArguments();
+
qt_startup_hook();
}
diff --git a/src/corelib/kernel/qcoreapplication_p.h b/src/corelib/kernel/qcoreapplication_p.h
index 61b334d..f167d2b 100644
--- a/src/corelib/kernel/qcoreapplication_p.h
+++ b/src/corelib/kernel/qcoreapplication_p.h
@@ -108,6 +108,9 @@ public:
int &argc;
char **argv;
void appendApplicationPathToLibraryPaths(void);
+ void processCommandLineArguments();
+
+ static QString qmljsDebugArguments(); // access arguments from other libraries
#ifndef QT_NO_TRANSLATION
QTranslatorList translators;
diff --git a/src/declarative/debugger/qdeclarativedebugserver.cpp b/src/declarative/debugger/qdeclarativedebugserver.cpp
index c664f96..67fd36b 100644
--- a/src/declarative/debugger/qdeclarativedebugserver.cpp
+++ b/src/declarative/debugger/qdeclarativedebugserver.cpp
@@ -49,7 +49,7 @@
#include <QtCore/QStringList>
#include <private/qobject_p.h>
-#include <private/qapplication_p.h>
+#include <private/qcoreapplication_p.h>
QT_BEGIN_NAMESPACE
@@ -169,7 +169,7 @@ QDeclarativeDebugServer *QDeclarativeDebugServer::instance()
if (!commandLineTested) {
commandLineTested = true;
- QApplicationPrivate *appD = static_cast<QApplicationPrivate*>(QObjectPrivate::get(qApp));
+ QCoreApplicationPrivate *appD = static_cast<QCoreApplicationPrivate*>(QObjectPrivate::get(qApp));
#ifndef QDECLARATIVE_NO_DEBUG_PROTOCOL
// ### remove port definition when protocol is changed
int port = 0;
@@ -177,26 +177,26 @@ QDeclarativeDebugServer *QDeclarativeDebugServer::instance()
bool ok = false;
// format: qmljsdebugger=port:3768[,block] OR qmljsdebugger=ost[,block]
- if (!appD->qmljsDebugArgumentsString().isEmpty()) {
+ if (!appD->qmljsDebugArguments().isEmpty()) {
if (!QDeclarativeEnginePrivate::qml_debugging_enabled) {
qWarning() << QString::fromLatin1(
"QDeclarativeDebugServer: Ignoring \"-qmljsdebugger=%1\". "
"Debugging has not been enabled.").arg(
- appD->qmljsDebugArgumentsString());
+ appD->qmljsDebugArguments());
return 0;
}
QString pluginName;
- if (appD->qmljsDebugArgumentsString().indexOf(QLatin1String("port:")) == 0) {
- int separatorIndex = appD->qmljsDebugArgumentsString().indexOf(QLatin1Char(','));
- port = appD->qmljsDebugArgumentsString().mid(5, separatorIndex - 5).toInt(&ok);
+ if (appD->qmljsDebugArguments().indexOf(QLatin1String("port:")) == 0) {
+ int separatorIndex = appD->qmljsDebugArguments().indexOf(QLatin1Char(','));
+ port = appD->qmljsDebugArguments().mid(5, separatorIndex - 5).toInt(&ok);
pluginName = QLatin1String("qmldbg_tcp");
- } else if (appD->qmljsDebugArgumentsString().contains(QLatin1String("ost"))) {
+ } else if (appD->qmljsDebugArguments().contains(QLatin1String("ost"))) {
pluginName = QLatin1String("qmldbg_ost");
ok = true;
}
- block = appD->qmljsDebugArgumentsString().contains(QLatin1String("block"));
+ block = appD->qmljsDebugArguments().contains(QLatin1String("block"));
if (ok) {
server = new QDeclarativeDebugServer();
@@ -213,22 +213,22 @@ QDeclarativeDebugServer *QDeclarativeDebugServer::instance()
qWarning() << QString::fromLatin1(
"QDeclarativeDebugServer: Ignoring \"-qmljsdebugger=%1\". "
"Remote debugger plugin has not been found.").arg(
- appD->qmljsDebugArgumentsString());
+ appD->qmljsDebugArguments());
}
} else {
qWarning() << QString::fromLatin1(
"QDeclarativeDebugServer: Ignoring \"-qmljsdebugger=%1\". "
"Format is -qmljsdebugger=port:<port>[,block]").arg(
- appD->qmljsDebugArgumentsString());
+ appD->qmljsDebugArguments());
}
}
#else
- if (!appD->qmljsDebugArgumentsString().isEmpty()) {
+ if (!appD->qmljsDebugArguments().isEmpty()) {
qWarning() << QString::fromLatin1(
"QDeclarativeDebugServer: Ignoring \"-qmljsdebugger=%1\". "
"QtDeclarative is not configured for debugging.").arg(
- appD->qmljsDebugArgumentsString());
+ appD->qmljsDebugArguments());
}
#endif
}
diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp
index c520fcf..a5fca58 100644
--- a/src/gui/kernel/qapplication.cpp
+++ b/src/gui/kernel/qapplication.cpp
@@ -506,7 +506,6 @@ bool QApplicationPrivate::fade_tooltip = false;
bool QApplicationPrivate::animate_toolbox = false;
bool QApplicationPrivate::widgetCount = false;
bool QApplicationPrivate::load_testability = false;
-QString QApplicationPrivate::qmljs_debug_arguments;
#ifdef QT_KEYPAD_NAVIGATION
# ifdef Q_OS_SYMBIAN
Qt::NavigationMode QApplicationPrivate::navigationMode = Qt::NavigationModeKeypadDirectional;
@@ -578,8 +577,6 @@ void QApplicationPrivate::process_cmdline()
QString s;
if (arg == "-qdevel" || arg == "-qdebug") {
// obsolete argument
- } else if (arg.indexOf("-qmljsdebugger=", 0) != -1) {
- qmljs_debug_arguments = 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) {
@@ -6192,11 +6189,6 @@ QPixmap QApplicationPrivate::getPixmapCursor(Qt::CursorShape cshape)
return QPixmap();
}
-QString QApplicationPrivate::qmljsDebugArgumentsString()
-{
- return qmljs_debug_arguments;
-}
-
QT_END_NAMESPACE
#include "moc_qapplication.cpp"
diff --git a/src/gui/kernel/qapplication_p.h b/src/gui/kernel/qapplication_p.h
index 74b0ee5..e444625 100644
--- a/src/gui/kernel/qapplication_p.h
+++ b/src/gui/kernel/qapplication_p.h
@@ -455,8 +455,6 @@ public:
static bool animate_toolbox;
static bool widgetCount; // Coupled with -widgetcount switch
static bool load_testability; // Coupled with -testability switch
- static QString qmljs_debug_arguments; // a string containing arguments for js/qml debugging.
- static QString qmljsDebugArgumentsString(); // access string from other libraries
#ifdef Q_WS_MAC
static bool native_modal_dialog_active;