From eb70e3ef57d8a26bed09abe18a4d089fcf9d137c Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Mon, 17 Mar 2025 11:11:33 +0100 Subject: [PATCH] Add -clientid command line option that adapts the ID for SingleApp When the app is started with "-client -clientid " it only reuses an instance that was also started with "-clientid ". It adds the ID as a postfix to the normal application ID that is used for the QtSingleApplication. Change-Id: I832eff84ff306bd4d615dcdc7cd99b7b92acc3b0 Reviewed-by: hjk --- src/app/main.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/app/main.cpp b/src/app/main.cpp index 90eaa719818..8feef335736 100644 --- a/src/app/main.cpp +++ b/src/app/main.cpp @@ -66,6 +66,7 @@ const char fixedOptionsC[] " -help Display this help\n" " -version Display program version\n" " -client Attempt to connect to already running first instance\n" + " -clientid A postfix for the ID used by -client\n" " -settingspath Override the default path where user settings are stored\n" " -installsettingspath Override the default path from where user-independent " "settings are read\n" @@ -82,6 +83,7 @@ const char HELP_OPTION4[] = "--help"; const char VERSION_OPTION[] = "-version"; const char VERSION_OPTION2[] = "--version"; const char CLIENT_OPTION[] = "-client"; +const char CLIENTID_OPTION[] = "-clientid"; const char SETTINGS_OPTION[] = "-settingspath"; const char INSTALL_SETTINGS_OPTION[] = "-installsettingspath"; const char TEST_OPTION[] = "-test"; @@ -370,6 +372,10 @@ Options parseCommandLine(int argc, char *argv[]) } else if (arg == TEMPORARY_CLEAN_SETTINGS1 || arg == TEMPORARY_CLEAN_SETTINGS2) { options.wantsCleanSettings = true; options.preAppArguments << arg; + } else if (arg == CLIENTID_OPTION && hasNext) { + ++it; + options.singleAppIdPostfix = nextArg; + options.preAppArguments << arg << nextArg; } else { // arguments that are still passed on to the application if (arg == STYLE_OPTION) options.hasStyleOption = true;