Skip to content
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

Merged
merged 1 commit into from
Oct 23, 2021

Conversation

Be-ing
Copy link
Contributor

@Be-ing Be-ing commented Oct 22, 2021

No description provided.

Copy link
Member

@daschuer daschuer left a 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.

@@ -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()) {
Copy link
Member

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:

DEBUG_ASSERT(!"Unexpected invalid key");

Copy link
Member

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.

Copy link
Contributor

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.

Copy link
Contributor

@uklotzde uklotzde Oct 23, 2021

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.

Copy link
Member

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.

@daschuer daschuer merged commit f2b1192 into mixxxdj:main Oct 23, 2021
@Be-ing Be-ing deleted the alias_debug_assert branch October 23, 2021 15:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants