summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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
-rw-r--r--tests/auto/qcoreapplication/tst_qcoreapplication.cpp8
6 files changed, 55 insertions, 23 deletions
diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp
index bee95eb0aa..2654a6cb62 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 61b334d2cf..f167d2b01b 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 c664f96018..67fd36b09f 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 c520fcf8c0..a5fca584bb 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 74b0ee58da..e4446257de 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;
diff --git a/tests/auto/qcoreapplication/tst_qcoreapplication.cpp b/tests/auto/qcoreapplication/tst_qcoreapplication.cpp
index 24bce0a607..533a3b8696 100644
--- a/tests/auto/qcoreapplication/tst_qcoreapplication.cpp
+++ b/tests/auto/qcoreapplication/tst_qcoreapplication.cpp
@@ -144,6 +144,14 @@ void tst_QCoreApplication::argc()
QCOMPARE(argc, 0);
QCOMPARE(app.argc(), 0);
}
+
+ {
+ int argc = 2;
+ char *argv[] = { "tst_qcoreapplication", "-qmljsdebugger=port:3768,block" };
+ QCoreApplication app(argc, argv);
+ QCOMPARE(argc, 1);
+ QCOMPARE(app.argc(), 1);
+ }
}
class EventGenerator : public QObject