Fix argument passing between rssguard instances.

This commit is contained in:
Martin Rotter 2021-03-30 10:02:58 +02:00
parent 40d32f3088
commit e7d366328f
2 changed files with 10 additions and 9 deletions

View File

@ -100,6 +100,8 @@
#define CLI_SIN_LONG "no-single-instance"
#define CLI_NDEBUG_SHORT "n"
#define CLI_NDEBUG_LONG "no-debug-output"
#define CLI_QUIT_INSTANCE "q"
#define CLI_IS_RUNNING "a"
#define HTTP_HEADERS_ACCEPT "Accept"
#define HTTP_HEADERS_CONTENT_TYPE "Content-Type"
@ -169,8 +171,6 @@
#define APP_CFG_PATH "config"
#define APP_CFG_FILE "config.ini"
#define APP_QUIT_INSTANCE "-q"
#define APP_IS_RUNNING "app_is_running"
#define APP_SKIN_USER_FOLDER "skins"
#define APP_SKIN_DEFAULT "vergilius"
#define APP_SKIN_METADATA_FILE "metadata.xml"

View File

@ -158,7 +158,8 @@ void Application::offerChanges() const {
bool Application::isAlreadyRunning() {
return m_allowMultipleInstances
? false
: sendMessage((QStringList() << APP_IS_RUNNING << Application::arguments().mid(1)).join(ARGUMENTS_LIST_SEPARATOR));
: sendMessage((QStringList() << QSL("-%1").arg(CLI_IS_RUNNING)
<< Application::arguments().mid(1)).join(ARGUMENTS_LIST_SEPARATOR));
}
FeedReader* Application:: feedReader() {
@ -351,26 +352,26 @@ void Application::parseCmdArgumentsFromOtherInstance(const QString& message) {
qDebugNN << LOGSEC_CORE
<< "Received"
<< QUOTE_W_SPACE(message)
<< "execution message from another application instance.";
<< "execution message.";
QStringList messages = message.split(ARGUMENTS_LIST_SEPARATOR);
QStringList messages = message.split(ARGUMENTS_LIST_SEPARATOR, Qt::SplitBehaviorFlags::SkipEmptyParts);
QCommandLineParser cmd_parser;
messages.prepend(qApp->applicationFilePath());
cmd_parser.addOption(QCommandLineOption(QStringList() << APP_QUIT_INSTANCE));
cmd_parser.addOption(QCommandLineOption(QStringList() << APP_IS_RUNNING));
cmd_parser.addOption(QCommandLineOption(QStringList() << CLI_QUIT_INSTANCE));
cmd_parser.addOption(QCommandLineOption(QStringList() << CLI_IS_RUNNING));
cmd_parser.addPositionalArgument("urls",
"List of URL addresses pointing to individual online feeds which should be added.",
"[url-1 ... url-n]");
cmd_parser.process(messages);
if (cmd_parser.isSet(APP_QUIT_INSTANCE)) {
if (cmd_parser.isSet(CLI_QUIT_INSTANCE)) {
quit();
return;
}
else if (cmd_parser.isSet(APP_IS_RUNNING)) {
else if (cmd_parser.isSet(CLI_IS_RUNNING)) {
showGuiMessage(APP_NAME, tr("Application is already running."), QSystemTrayIcon::MessageIcon::Information);
mainForm()->display();
}