Skip to content

Commit

Permalink
option '-psn_*' should set Qt and stop parsing
Browse files Browse the repository at this point in the history
When Gate.app is double-clicked, the application gets a process serial number
in the form -psn_0_1234567. This should start the Qt interface automatically
and prevent parsing command-line option with getopt_long().
  • Loading branch information
mojca committed Jul 17, 2013
1 parent 635b457 commit f3ac52f
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions Gate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,17 @@ int main( int argc, char* argv[] )
{ "param", required_argument, 0, 'a' }
};

// Getting the option
c = getopt_long( argc, argv, "ha:", longOptions, &optionIndex );

// If the program was started by double-clicking on the application bundle on Mac OS X
// rather than from the command-line, enable Qt and don't try to process other options;
// argv[1] contains a process serial number in the form -psn_0_1234567
if( argc > 1 && memcmp( argv[1], "-psn_", 5 ) == 0 ) {
argc = 1;
isQt = 1;
break;
} else {
// Getting the option
c = getopt_long( argc, argv, "ha:", longOptions, &optionIndex );
}
// Exit the loop if -1
if( c == -1 ) break;

Expand Down

0 comments on commit f3ac52f

Please sign in to comment.