From bfa0202814c872f1486fa20783823634cdfecd1c Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Mon, 17 Mar 2025 10:40:07 +0100 Subject: [PATCH] Qml(Lite)Designer: Separate SingleAppInstances Qt Design Studio has the option -qml-lite-designer that starts it in a simplified mode, e.g. for opening individual files from Qt Creator. When such a "lite" QDS is already running, we can and want to reuse it with the "-client" option, but if a "normal" QDS is running we do not want that to open instead. So we need to separate the SingleApp IDs depending on the command line option. It is a bit ugly to hack the -qml-lite-designer into the global command line handling, and it would probably be nicer to add a separate, generic "-singleappid " command line option that could be used by Qt Creator when starting QDS. But that would require to wait for that new command line option to roll out with QDS before we can use it in QtC. This can still be added and switched to later when we assume that most QDS installations have it. Task-number: QTCREATORBUG-31005 Change-Id: Iad1d4ff7bf7ec7aa40cb2eae055ab8847a2e6730 Reviewed-by: hjk --- src/app/main.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/app/main.cpp b/src/app/main.cpp index bf05a8946ec..90eaa719818 100644 --- a/src/app/main.cpp +++ b/src/app/main.cpp @@ -86,6 +86,7 @@ const char SETTINGS_OPTION[] = "-settingspath"; const char INSTALL_SETTINGS_OPTION[] = "-installsettingspath"; const char TEST_OPTION[] = "-test"; const char STYLE_OPTION[] = "-style"; +const char QML_LITE_DESIGNER_OPTION[] = "-qml-lite-designer"; const char TEMPORARY_CLEAN_SETTINGS1[] = "-temporarycleansettings"; const char TEMPORARY_CLEAN_SETTINGS2[] = "-tcs"; const char PID_OPTION[] = "-pid"; @@ -325,6 +326,7 @@ struct Options QString installSettingsPath; QStringList customPluginPaths; QString uiLanguage; + QString singleAppIdPostfix; // list of arguments that were handled and not passed to the application or plugin manager QStringList preAppArguments; // list of arguments to be passed to the application or plugin manager @@ -373,6 +375,8 @@ Options parseCommandLine(int argc, char *argv[]) options.hasStyleOption = true; if (arg == TEST_OPTION) options.hasTestOption = true; + if (arg == QML_LITE_DESIGNER_OPTION) + options.singleAppIdPostfix = QML_LITE_DESIGNER_OPTION; options.appArguments.push_back(*it); } ++it; @@ -701,9 +705,10 @@ int main(int argc, char **argv) // create a custom Qt message handler that shows messages in a bare bones UI // if creation of the QGuiApplication fails. auto handler = std::make_unique(); - std::unique_ptr - appPtr(SharedTools::createApplication(QLatin1String(Core::Constants::IDE_DISPLAY_NAME), - numberOfArguments, options.appArguments.data())); + const QString singleAppId = QString(Core::Constants::IDE_DISPLAY_NAME) + + options.singleAppIdPostfix; + std::unique_ptr appPtr( + SharedTools::createApplication(singleAppId, numberOfArguments, options.appArguments.data())); handler.reset(); SharedTools::QtSingleApplication &app = *appPtr; QCoreApplication::setApplicationName(Core::Constants::IDE_CASED_ID);