Skip to content

Commit

Permalink
Fix printing user errors in musescore.cpp
Browse files Browse the repository at this point in the history
Support translating messages.

Avoid qFatal since it generates a core dump and is used for
untranslated developer messages.

Use ::exit() because exit() refers to QCoreApplication::exit().

Fixes building with -Werror=format-security.
  • Loading branch information
orivej committed Dec 19, 2020
1 parent 88fa80c commit 8d32b59
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions mscore/musescore.cpp
Expand Up @@ -2001,7 +2001,8 @@ MuseScore::MuseScore()
const bool loadSuccess = _loginManager->load();

if (cliSaveOnline && !loadSuccess) {
qFatal(qUtf8Printable(tr("No login credentials stored. Please sign in via the GUI.")));
fprintf(stderr, "%s\n", qPrintable(tr("No login credentials stored. Please sign in via the GUI.")));
::exit(EXIT_FAILURE);
}
}

Expand Down Expand Up @@ -7768,7 +7769,8 @@ MuseScoreApplication::CommandLineParseResult MuseScoreApplication::parseCommandL
MScore::noGui = true;

if (parser.positionalArguments().isEmpty()) {
qFatal("Must specify at least one score to save online.");
fprintf(stderr, "%s\n", qPrintable(tr("Must specify at least one score to save online.")));
::exit(EXIT_FAILURE);
}
}

Expand Down Expand Up @@ -7822,8 +7824,10 @@ MuseScoreApplication::CommandLineParseResult MuseScoreApplication::parseCommandL
diffMode = true;
}
if (parser.isSet("run-test-script")) {
if (rawDiffMode || diffMode)
qFatal("incompatible options");
if (rawDiffMode || diffMode) {
fprintf(stderr, "%s\n", qPrintable(tr("--run-test-script is incompatible with --diff and --raw-diff")));
::exit(EXIT_FAILURE);
}
MScore::noGui = true;
scriptTestMode = true;
}
Expand Down Expand Up @@ -7853,11 +7857,15 @@ MuseScoreApplication::CommandLineParseResult MuseScoreApplication::parseCommandL
}
}
if (rawDiffMode || diffMode) {
if (argv.size() != 2)
qFatal("Only two scores are needed for performing a comparison");
if (argv.size() != 2) {
fprintf(stderr, "%s\n", qPrintable(tr("Only two scores are needed for performing a comparison")));
::exit(EXIT_FAILURE);
}
}
if (scriptTestMode && argv.empty()) {
fprintf(stderr, "%s\n", qPrintable(tr("Please specify scripts to execute")));
::exit(EXIT_FAILURE);
}
if (scriptTestMode && argv.empty())
qFatal("Please specify scripts to execute");

parseResult.argv = argv;
return parseResult;
Expand Down

0 comments on commit 8d32b59

Please sign in to comment.