on xenial help sign in
Add env var to enable js debugging/profiling even if not built on debug mode
09963e8Albert Astals Cid
src/Dash/main.cpp+5
@@ -27,6 +27,7 @@
27#include <libintl.h>
27#include <libintl.h>
28
28
29#include <paths.h>
29#include <paths.h>
30+#include "../qmldebuggerutils.h"
30#ifdef UNITY8_ENABLE_TOUCH_EMULATION
31#ifdef UNITY8_ENABLE_TOUCH_EMULATION
31 #include "../MouseTouchAdaptor.h"
32 #include "../MouseTouchAdaptor.h"
32#endif
33#endif
@@ -34,6 +35,10 @@
34
35
35int main(int argc, const char *argv[])
36int main(int argc, const char *argv[])
36{
37{
38+ if (enableQmlDebugger(argc, argv)) {
39+ QQmlDebuggingEnabler qQmlEnableDebuggingHelper(true);
40+ }
41+
37 QGuiApplication *application = new QGuiApplication(argc, (char**)argv);
42 QGuiApplication *application = new QGuiApplication(argc, (char**)argv);
38
43
39 QCommandLineParser parser;
44 QCommandLineParser parser;
src/main.cpp+5
@@ -16,6 +16,7 @@
16
16
17// local
17// local
18#include "ShellApplication.h"
18#include "ShellApplication.h"
19+#include "qmldebuggerutils.h"
19
20
20int main(int argc, const char *argv[])
21int main(int argc, const char *argv[])
21{
22{
@@ -25,6 +26,10 @@ int main(int argc, const char *argv[])
25 isMirServer = true;
26 isMirServer = true;
26 }
27 }
27
28
29+ if (enableQmlDebugger(argc, argv)) {
30+ QQmlDebuggingEnabler qQmlEnableDebuggingHelper(true);
31+ }
32+
28 ShellApplication *application = new ShellApplication(argc, (char**)argv, isMirServer);
33 ShellApplication *application = new ShellApplication(argc, (char**)argv, isMirServer);
29
34
30 int result = application->exec();
35 int result = application->exec();
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