From 3f78df5725c6fa4bf6ec764244cc6e2f95413001 Mon Sep 17 00:00:00 2001 From: John Maguire Date: Sat, 24 Jul 2010 14:57:56 +0000 Subject: [PATCH] Fix the parsing of Finder command line options. Fixes issue #537 --- src/core/commandlineoptions.cpp | 14 ++++++++++++++ src/main.cpp | 8 -------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/core/commandlineoptions.cpp b/src/core/commandlineoptions.cpp index 881d02d13..c576d03dd 100644 --- a/src/core/commandlineoptions.cpp +++ b/src/core/commandlineoptions.cpp @@ -71,6 +71,20 @@ CommandlineOptions::CommandlineOptions(int argc, char** argv) engine_(Engine::Type_QtPhonon) #endif { +#ifdef Q_OS_DARWIN + // Remove -psn_xxx option that Mac passes when opened from Finder. + 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]; + } + --argc_; + break; + } + } +#endif } bool CommandlineOptions::Parse() { diff --git a/src/main.cpp b/src/main.cpp index a0f64a48f..49b0b1360 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -86,14 +86,6 @@ int main(int argc, char *argv[]) { // Do Mac specific startup to get media keys working. // This must go before QApplication initialisation. mac::MacMain(); - - // Strip mac command line option. - for (int i = 0; i < argc; ++i) { - QString arg(argv[i]); - if (arg.startsWith("-psn")) { - argv[i][0] = '\0'; - } - } #endif QCoreApplication::setApplicationName("Clementine");