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_;