From 7650c1eddccc1b63b4dc26ad044fd45bb7d23045 Mon Sep 17 00:00:00 2001 From: David Sansome Date: Sat, 11 Dec 2010 10:04:17 +0000 Subject: [PATCH] Remove "-session" from the commandline to fix session management on KDE. Fixes issue #769 --- src/core/commandlineoptions.cpp | 18 ++++++++++++------ src/core/commandlineoptions.h | 1 + 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/core/commandlineoptions.cpp b/src/core/commandlineoptions.cpp index 1d80c4f26..9e2f0611d 100644 --- a/src/core/commandlineoptions.cpp +++ b/src/core/commandlineoptions.cpp @@ -75,18 +75,24 @@ CommandlineOptions::CommandlineOptions(int argc, char** argv) { #ifdef Q_OS_DARWIN // Remove -psn_xxx option that Mac passes when opened from Finder. + RemoveArg("-psn", 1); +#endif + + // Remove the -session option that KDE passes + RemoveArg("-session", 2); +} + +void CommandlineOptions::RemoveArg(const QString& starts_with, int count) { for (int i = 0; i < argc_; ++i) { QString opt(argv_[i]); - if (opt.startsWith("-psn")) { - // Shuffle remaining args. - for (int j = i; j < argc_; ++j) { - argv_[j] = argv_[j+1]; + if (opt.startsWith(starts_with)) { + for (int j = i; j < argc_ - count + 1; ++j) { + argv_[j] = argv_[j+count]; } - --argc_; + argc_ -= count; break; } } -#endif } bool CommandlineOptions::Parse() { diff --git a/src/core/commandlineoptions.h b/src/core/commandlineoptions.h index ea24541c4..36335b29f 100644 --- a/src/core/commandlineoptions.h +++ b/src/core/commandlineoptions.h @@ -79,6 +79,7 @@ class CommandlineOptions { }; QString tr(const char* source_text); + void RemoveArg(const QString& starts_with, int count); private: int argc_;