-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
ControlDoublePrivate: change warnings to debug assertions #4473
Conversation
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 way we loose the info which Control is affected. Please keep the warning before the assertion.
cb0888f
to
7f55425
Compare
@@ -109,14 +109,14 @@ void ControlDoublePrivate::insertAlias(const ConfigKey& alias, const ConfigKey& | |||
MMutexLocker locker(&s_qCOHashMutex); | |||
|
|||
auto it = s_qCOHash.constFind(key); | |||
if (it == s_qCOHash.constEnd()) { | |||
qWarning() << "WARNING: ControlDoublePrivate::insertAlias called for null control" << key; | |||
VERIFY_OR_DEBUG_ASSERT(it != s_qCOHash.constEnd()) { |
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.
It doe not work that way around, because the warning is no longer issued after that assertion.
You can find a working pattern here:
Line 140 in 625cebd
DEBUG_ASSERT(!"Unexpected invalid key"); |
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.
Please follow the link to see the whole solution.
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.
The proposed pattern is cumbersome and only used rarely in the code base. We didn't agree on it.
During development triggering an assertion is intended. In the release version assertions are disabled and the warning is printed instead in case we missed an occurrence. I remember to have used this pattern frequently.
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.
TL;DR I disagree and propose to use VERIFY_OR_DEBUG_ASSERT + qWarning() 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.
You are right that the linked solution is a bit cumbersome due to the two instances giving a message. Maybe it is worth to consider a macro that allows to give more context in a failed assertion case.
But anyway this PR prints:
critical [Main] DEBUG ASSERT: "it != s_qCOHash.constEnd()" in function static void ControlDoublePrivate::insertAlias(const ConfigKey&, const ConfigKey&) at /home/sperry/workspace/i18n/src/control/control.cpp:112
in case of assertions enabled which is the case during development and
warning [Main] cannot create alias for null control "[EqualizerRack1_[Channel4]_Effect1]" , "typo"
in a release builds
With the linked pattern we would have have something like
warning [Main] cannot create alias for null control "[EqualizerRack1_[Channel4]_Effect1]" , "typo"
critical [Main] DEBUG ASSERT: "false" in function static void ControlDoublePrivate::insertAlias(const ConfigKey&, const ConfigKey&) at /home/sperry/workspace/i18n/src/control/control.cpp:112
Which is IMHO clearly an improvement but more chatty than necessary.
After reading your comment, I have realized that this issue is not that important here, because we do not introduce aliases frequently. In favor of deescalation, I will merge this now.
No description provided.