New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[MU3] Fix printing user errors in musescore.cpp #7118
Conversation
mscore/musescore.cpp
Outdated
@@ -2001,7 +2001,7 @@ MuseScore::MuseScore() | |||
const bool loadSuccess = _loginManager->load(); | |||
|
|||
if (cliSaveOnline && !loadSuccess) { | |||
qFatal(qUtf8Printable(tr("No login credentials stored. Please sign in via the GUI."))); | |||
qFatal("No login credentials stored. Please sign in via the GUI."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Veto. This way that text is not translatable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No other qFatal is translatable. (I don't think that qFatal, qWarning, and other developer messages need translation.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMHO they do, all of them.
Not the qDebug() ones though, not sure about qWarning().
If at that place the translations engine is available, which for example it is not at the place wherethe Usage message is printed
At this place translations are avaibable though, as far as I can tell.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about qFatal("%s", qUtf8Printable(tr("No login credentials stored. Please sign in via the GUI.")));
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@orivej, does this work:
QString msg = tr("No login credentials stored. Please sign in via the GUI.");
qFatal(qUtf8Printable(msg));
Or
auto msg = qUtf8Printable(tr("No login credentials stored. Please sign in via the GUI."));
qFatal(msg);
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, makes sense (we really don't want a core dump here), so here we might better be using fprintf(stderr, "...")
or std::cerr << "..."
followed by exit(EXIT_FAILURE);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Jojo-Schmitz, what about qWarning() << "..."
followed by exit(EXIT_FAILURE)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would work too I guess. Not sure though whether either of these functions prefixes the (error) message with "Fatal:", "Warning:" or some such
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and whether and how it works on Windows commandline (but there I'm not sure about `cerr? and the likes either)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK. I had to use ::exit
because exit
resolves into QCoreApplication::exit()
(exit from the main loop), which does nothing when the main loop is not running.
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.
Resolves: #6914 (comment)
v3.6_public_beta fails to build with Nixpkgs because by default it enables
-Wformat -Wformat-security -Werror=format-security
, which does not acceptqFatal(qUtf8Printable(tr("…")))
. This fixes it by replacing qFatal with fprintf. (See also commit description.)