-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
change SKIN_WARNING to show the skin file:line first, then c++ context #12253
Conversation
2f8b5c2
to
925a8ec
Compare
I tested this an works as expected, apart that I get absolute path for the XML file (independent of the change in this PR).
Why do we print this as warning and use the words SKIN ERROR? This does not match to me. |
Well, it's not fatal for the app, it's just SKIN PARSING ERROR to be exact. |
Maybe |
Makes sense. I'll check if SKIN_WARNING is indeed only used for parsing errors. |
925a8ec
to
7a7f2b4
Compare
It is. I changed it to |
Or even shorter: warning [Main] parsing: |
@@ -1049,7 +1067,7 @@ QWidget* LegacySkinParser::parseText(const QDomElement& node) { | |||
QString group = lookupNodeGroup(node); | |||
BaseTrackPlayer* pPlayer = m_pPlayerManager->getPlayer(group); | |||
if (!pPlayer) { | |||
SKIN_WARNING(node, *m_pContext) << "No player found for group:" << group; | |||
SKIN_WARNING(node, *m_pContext, QStringLiteral("No player found for group:").arg(group)); |
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.
Here is the %1 missing.
I am afraid the arg() version is more expensive than the original.
I have an idea to keep the stream type working. See my other comment.
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.
While I understand the argument to aim for best possible performance and appreciate the effort you put into the skinWarning class example below, I do wonder if this fully applies here. It's a warning after all indicating the GUI won't be functional as expected, and if a significant amount of warnings is printed this small performance regression is the least we should be worried about IMHO.
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.
This does not apply here, sure. The mandatory issue is only the missing %1
file, | ||
QString::number(line)) | ||
.toUtf8() | ||
.constData(); |
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.
To allow keep using the stream operators you may inherit from QDebug()
(Not sure if it is worth the effort)
Not yet working idea:
class SkinWarning : public QDebug {
public:
SkinWarning(const char* file,
const int line,
const QDomNode& node,
const QString& message)
: QDebug(QtWarningMsg) {
*this << "Skin parsing failed at" << QString(m_xmlPath,) + QChar(':') + QString::number(node.lineNumber());
}
~SkinWarning() {
*this << QString(m_file) + QChar(':') + QString::number(m_line);
}
private:
const char* m_file,
const int m_line,
};
```
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.
Interesting! Didn't think about creating a dedicated class.
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.
What are your plans with this PR?
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.
I'll try your suggestions, and if it gives my too much headaches I'd rather merge this as is.
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.
aaah, oooh, FILE and LINE are pre-processor macros. A little less magic now.
Anyway, I gave it a shot but it doesn't work as expected, or I just didn't fully understand how you plan to implement. I assumed you aimed to leave all SKIN_WARNING()
calls unchanged.
https://github.com/ronso0/mixxx/pull/new/skin-warning-class incl. one commit with hotcue 0 to trigger a warning.
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.
If you are motivated and manage to fix it, fine. I can re-apply the individual tweaks on top of your branch.
Otherwise let's merge this as is, maybe drop a comment so someone can try again later.
src/skin/legacy/legacyskinparser.cpp
Outdated
<< QString::fromStdString(attribute.value()); | ||
SKIN_WARNING(skinDocument, | ||
*m_pContext, | ||
QStringLiteral("Error reading double value from skin attribute: %1") |
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.
QStringLiteral("Error reading double value from skin attribute: %1") | |
QStringLiteral("Failed reading double value from skin attribute: %1") |
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.
done.
7a7f2b4
to
72b6f1c
Compare
LGTM! Thank you! |
The failing skin xml line can now be spotted much easier, especially if your source directory path is rather long.
before:
now:
The xml path and the error message are meaningful already, so maybe we can omit
/path/to/mixxx-source-file/:123
altogether. Just my impression, I didn't check all usages.