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>
+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 };
// Support for introspection
QSignalSpyCallbackSet Q_CORE_EXPORT qt_signal_spy_callback_set = { 0, 0, 0, 0 };
+ d->processCommandLineArguments();
+
static uint attribs;
static inline bool testAttribute(uint flag) { return attribs & (1 << flag); }
static int app_compile_version;
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; }
static bool quitOnLastWindowClosed;
static bool quitOnLastWindowClosed;
- QString qmljs_debug_arguments; // a string containing arguments for js/qml debugging.
- inline QString qmljsDebugArgumentsString() { return qmljs_debug_arguments; }
QString s;
if (arg == "-qdevel" || arg == "-qdebug") {
// obsolete argument
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) {
} else if (arg.indexOf("-style=", 0) != -1) {
s = QString::fromLocal8Bit(arg.right(arg.length() - 7).toLower());
} else if (arg == "-style" && i < argc-1) {
QCOMPARE(argc, 0);
QCOMPARE(app.argc(), 0);
}
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
}
class EventGenerator : public QObject