From 5285243a40734bc2ad7cda93779d21155a4b89bf Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Wed, 28 Feb 2024 20:07:39 +0100 Subject: [PATCH] mobile: turn testqml into a std::string Signed-off-by: Berthold Stoeger --- core/subsurfacestartup.cpp | 5 ++--- core/subsurfacestartup.h | 9 ++++++--- subsurface-helper.cpp | 4 ++-- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/core/subsurfacestartup.cpp b/core/subsurfacestartup.cpp index 23e91bd4f..3fb7ec904 100644 --- a/core/subsurfacestartup.cpp +++ b/core/subsurfacestartup.cpp @@ -17,7 +17,7 @@ extern void show_computer_list(); int quit, force_root, ignore_bt; #ifdef SUBSURFACE_MOBILE_DESKTOP -char *testqml = NULL; +std::string testqml; #endif /* @@ -169,8 +169,7 @@ extern "C" void parse_argument(const char *arg) } #elif SUBSURFACE_MOBILE_DESKTOP if (strncmp(arg, "--testqml=", sizeof("--testqml=") - 1) == 0) { - testqml = (char *)malloc(strlen(arg) - sizeof("--testqml=") + 1); - strcpy(testqml, arg + sizeof("--testqml=") - 1); + testqml = arg + sizeof("--testqml=") - 1; return; } #endif diff --git a/core/subsurfacestartup.h b/core/subsurfacestartup.h index d62a4b92e..6f40f7abd 100644 --- a/core/subsurfacestartup.h +++ b/core/subsurfacestartup.h @@ -10,9 +10,6 @@ extern "C" { extern bool imported; extern int quit, force_root, ignore_bt; -#ifdef SUBSURFACE_MOBILE_DESKTOP -extern char *testqml; -#endif void setup_system_prefs(void); void parse_argument(const char *arg); @@ -24,6 +21,12 @@ extern char *settings_suffix; #ifdef __cplusplus } + +#ifdef SUBSURFACE_MOBILE_DESKTOP +#include +extern std::string testqml; +#endif + #endif #endif // SUBSURFACESTARTUP_H diff --git a/subsurface-helper.cpp b/subsurface-helper.cpp index 690b05e9c..1a2554101 100644 --- a/subsurface-helper.cpp +++ b/subsurface-helper.cpp @@ -133,8 +133,8 @@ void run_mobile_ui(double initial_font_size) qmlRegisterUncreatableType("org.subsurfacedivelog.mobile",1,0,"ExportType","Enum is not a type"); #ifdef SUBSURFACE_MOBILE_DESKTOP - if (testqml) { - QString fileLoad(testqml); + if (!testqml.empty()) { + QString fileLoad(testqml.c_str()); fileLoad += "/main.qml"; engine.load(QUrl(fileLoad)); } else {