Skip to content

Commit

Permalink
Cleanup Argument parser.
Browse files Browse the repository at this point in the history
Use QCommandLineParser instead of buggy hand crafted one.
  • Loading branch information
poelzi committed Feb 17, 2021
1 parent 6471e17 commit 1fa364f
Show file tree
Hide file tree
Showing 4 changed files with 193 additions and 166 deletions.
11 changes: 5 additions & 6 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,6 @@ int main(int argc, char * argv[]) {
QCoreApplication::setApplicationName(Version::applicationName());
QCoreApplication::setApplicationVersion(Version::version());

// Construct a list of strings based on the command line arguments
CmdlineArgs& args = CmdlineArgs::Instance();
if (!args.Parse(argc, argv)) {
args.printUsage();
return kParseCmdlineArgsErrorExitCode;
}

// If you change this here, you also need to change it in
// ErrorDialogHandler::errorDialog(). TODO(XXX): Remove this hack.
Expand All @@ -90,6 +84,11 @@ int main(int argc, char * argv[]) {

MixxxApplication app(argc, argv);

// Construct a list of strings based on the command line arguments
CmdlineArgs& args = CmdlineArgs::Instance();
if (!args.Parse(app.arguments())) {
return kParseCmdlineArgsErrorExitCode;
}

#ifdef __APPLE__
QDir dir(QApplication::applicationDirPath());
Expand Down
7 changes: 6 additions & 1 deletion src/test/mixxxtest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,12 @@ QScopedPointer<MixxxApplication> MixxxTest::s_pApplication;
MixxxTest::ApplicationScope::ApplicationScope(int& argc, char** argv) {
// Construct a list of strings based on the command line arguments
CmdlineArgs args;
const bool argsParsed = args.Parse(argc, argv);
QStringList argList;
for (int i = 0; i < argc; i++) {
argList << QString::fromLocal8Bit(argv[i]);
}

const bool argsParsed = args.Parse(argList);
Q_UNUSED(argsParsed);
DEBUG_ASSERT(argsParsed);

Expand Down
Loading

0 comments on commit 1fa364f

Please sign in to comment.