feat: add qml debugging

task: status-im/status-desktop#6973
This commit is contained in:
Patryk Osmaczko 2022-08-11 11:20:13 +02:00 committed by Michał
parent 109e45966b
commit eac67137c0
2 changed files with 22 additions and 1 deletions

View File

@ -29,6 +29,11 @@ macro(add_target name type)
target_link_libraries(${name} PRIVATE Qt5::Core Qt5::Gui Qt5::Widgets Qt5::Qml Qt5::Quick Qt5::Network Qt5::Multimedia SortFilterProxyModel) target_link_libraries(${name} PRIVATE Qt5::Core Qt5::Gui Qt5::Widgets Qt5::Qml Qt5::Quick Qt5::Network Qt5::Multimedia SortFilterProxyModel)
target_compile_definitions(${name} PRIVATE $<$<CONFIG:Debug>:QT_QML_DEBUG>)
if(DEFINED QML_DEBUG_PORT)
target_compile_definitions(${name} PRIVATE QML_DEBUG_PORT=${QML_DEBUG_PORT})
endif()
# for DOtherSide.pc # for DOtherSide.pc
set(PC_REQUIRES "Qt5Core, Qt5Gui, Qt5Widgets, Qt5Qml, Qt5Quick, Qt5Network, Qt5DBus, Qt5Multimedia SortFilterProxyModel") set(PC_REQUIRES "Qt5Core, Qt5Gui, Qt5Widgets, Qt5Qml, Qt5Quick, Qt5Network, Qt5DBus, Qt5Multimedia SortFilterProxyModel")
if (${Qt5QuickControls2_FOUND}) if (${Qt5QuickControls2_FOUND})

View File

@ -174,8 +174,24 @@ void dos_qguiapplication_initialize_opengl()
void dos_qguiapplication_create() void dos_qguiapplication_create()
{ {
// The parameters argc and argv and the strings pointed to by the argv array shall be modifiable by the program,
// and retain their last-stored values between program startup and program termination.
// In other words: argv strings can't be string literals!
const auto toCharPtr = [](const QString& str) {
auto bytes = str.toLocal8Bit();
char *data = new char[bytes.size() + 1];
strcpy(data, bytes.data());
return data; // we don't care about memory leak here
};
#ifdef QML_DEBUG_PORT
static int argc = 2;
static char *argv[] = {toCharPtr(QStringLiteral("Status")), toCharPtr(QString("-qmljsdebugger=port:%1,block").arg(QML_DEBUG_PORT))};
#else
static int argc = 1; static int argc = 1;
static char *argv[] = {(char*)"Status"}; static char *argv[] = {toCharPtr(QStringLiteral("Status"))};
#endif
new QGuiApplication(argc, argv); new QGuiApplication(argc, argv);
register_meta_types(); register_meta_types();
} }