on xenial help sign in
Make enabling the qml debugger depend on the -qmljsdebugger command line option being there or not
commit3540e102047b3c806171c9000a5e89171b60ae92 authorAlbert Astals Cid <albert.astals@canonical.com> dateFri 8 Apr 2016, 11:31 (11 years ago) parent762a4ce
3 files changed+40−5
src/Dash/main.cpp+5−4 src/main.cpp+2−1 src/qmldebuggerutils.h+33
src/Dash/main.cpp+5−4
@@ -27,6 +27,7 @@
2727#include <libintl.h>
2828
2929#include <paths.h>
30+#include "../qmldebuggerutils.h"
3031#ifdef UNITY8_ENABLE_TOUCH_EMULATION
3132 #include "../MouseTouchAdaptor.h"
3233#endif
@@ -34,6 +35,10 @@
3435
3536int main(int argc, const char *argv[])
3637{
38+ if (enableQmlDebugger(argc, argv)) {
39+ QQmlDebuggingEnabler qQmlEnableDebuggingHelper(true);
40+ }
41+
3742 QGuiApplication *application = new QGuiApplication(argc, (char**)argv);
3843
3944 QCommandLineParser parser;
@@ -73,10 +78,6 @@ int main(int argc, const char *argv[])
7378 }
7479 }
7580
76− if (getenv("ENABLE_QML_DEBUGGER")) {
77− QQmlDebuggingEnabler qQmlEnableDebuggingHelper(true);
78− }
79−
8081 bindtextdomain("unity8", translationDirectory().toUtf8().data());
8182 textdomain("unity8");
8283
src/main.cpp+2−1
@@ -16,6 +16,7 @@
1616
1717// local
1818#include "ShellApplication.h"
19+#include "qmldebuggerutils.h"
1920
2021int main(int argc, const char *argv[])
2122{
@@ -25,7 +26,7 @@ int main(int argc, const char *argv[])
2526 isMirServer = true;
2627 }
2728
28− if (getenv("ENABLE_QML_DEBUGGER")) {
29+ if (enableQmlDebugger(argc, argv)) {
2930 QQmlDebuggingEnabler qQmlEnableDebuggingHelper(true);
3031 }
3132
src/qmldebuggerutils.hnew file+33
@@ -0,0 +1,33 @@
1+/*
2+ * Copyright (C) 2016 Canonical, Ltd.
3+ *
4+ * This program is free software; you can redistribute it and/or modify
5+ * it under the terms of the GNU General Public License as published by
6+ * the Free Software Foundation; version 3.
7+ *
8+ * This program is distributed in the hope that it will be useful,
9+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+ * GNU General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ */
16+
17+#ifndef QMLDEBUGGERUTILS_H
18+#define QMLDEBUGGERUTILS_H
19+
20+bool enableQmlDebugger(int argc, const char *argv[])
21+{
22+ for (int i = 1; i < argc; ++i) {
23+ QByteArray arg = argv[i];
24+ if (arg.startsWith("--"))
25+ arg.remove(0, 1);
26+ if (arg.startsWith("-qmljsdebugger=") || (arg == "-qmljsdebugger" && i < argc - 1)) {
27+ return true;
28+ }
29+ }
30+ return false;
31+}
32+
33+#endif