Skip to content

Commit 3540e10

Browse files
committed
Make enabling the qml debugger depend on the -qmljsdebugger command line option being there or not
1 parent 762a4ce commit 3540e10

File tree

3 files changed

+40
-5
lines changed

3 files changed

+40
-5
lines changed

src/Dash/main.cpp

+5-4
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,18 @@
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
3334
#include "../CachingNetworkManagerFactory.h"
3435

3536
int 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
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
// local
1818
#include "ShellApplication.h"
19+
#include "qmldebuggerutils.h"
1920

2021
int 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.h

+33
Original file line numberDiff line numberDiff line change
@@ -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

0 commit comments

Comments
 (0)