diff options
author | Kai Koehne <kai.koehne@nokia.com> | 2011-09-19 10:56:12 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-09-19 16:37:51 +0200 |
commit | 9a096d9eb078f83b1e6f934ebaf863145f067fbc (patch) | |
tree | 45e811e81566f6274b2b8341d3549347538ffb80 | |
parent | 86ad092dff995f10d30022bb4e4a8955063dc3d1 (diff) |
Move handling of -qmljsdebugger argument to QCoreApplication
Move handling of -qmljsdebugger= argument from QApplication
to QCoreApplication. It makes sense to allow debugging also
for applications based on QCoreApplication (which we intend
to support in QtDeclarative).
Change-Id: I5a03a4510fc166cea5aad146da673ee0e7cd5d36
Reviewed-on: http://codereview.qt-project.org/5121
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Kent Hansen <kent.hansen@nokia.com>
-rw-r--r-- | src/corelib/kernel/qcoreapplication.cpp | 24 | ||||
-rw-r--r-- | src/corelib/kernel/qcoreapplication_p.h | 4 | ||||
-rw-r--r-- | src/gui/kernel/qguiapplication_p.h | 2 | ||||
-rw-r--r-- | src/widgets/kernel/qapplication.cpp | 2 | ||||
-rw-r--r-- | tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp | 8 |
5 files changed, 36 insertions, 4 deletions
diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index d716c7b0f6..d7fb9d3270 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -210,6 +210,28 @@ bool QCoreApplicationPrivate::checkInstance(const char *function) return b; } +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 }; @@ -674,6 +696,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 0914b24a16..d61a5a1bf5 100644 --- a/src/corelib/kernel/qcoreapplication_p.h +++ b/src/corelib/kernel/qcoreapplication_p.h @@ -141,6 +141,10 @@ public: static uint attribs; static inline bool testAttribute(uint flag) { return attribs & (1 << flag); } static int app_compile_version; + + void processCommandLineArguments(); + QString qmljs_debug_arguments; // a string containing arguments for js/qml debugging. + inline QString qmljsDebugArgumentsString() { return qmljs_debug_arguments; } }; QT_END_NAMESPACE diff --git a/src/gui/kernel/qguiapplication_p.h b/src/gui/kernel/qguiapplication_p.h index 9b817035a4..7ee95b777f 100644 --- a/src/gui/kernel/qguiapplication_p.h +++ b/src/gui/kernel/qguiapplication_p.h @@ -175,8 +175,6 @@ public: static bool quitOnLastWindowClosed; - QString qmljs_debug_arguments; // a string containing arguments for js/qml debugging. - inline QString qmljsDebugArgumentsString() { return qmljs_debug_arguments; } private: void init(); diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index ff3fd89712..2dfdbafabe 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -536,8 +536,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) { diff --git a/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp b/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp index 99f0941ac2..62275f841a 100644 --- a/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp +++ b/tests/auto/corelib/kernel/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 |