Prevent wrong usage of Control Objects with assertions#2896
Prevent wrong usage of Control Objects with assertions#2896daschuer merged 16 commits intomixxxdj:2.3from
Conversation
|
|
||
| enum class ControlFlag { | ||
| None = 0, | ||
| NoWarnIfMissing = 1, |
There was a problem hiding this comment.
The negation make the code harder to understand. Why not WarnIfMissing and WarnAndAssertIfMissing? Using flags is not necessary according to the code, because the assertion is nested in the warning path. Use a simple enum class instead.
There was a problem hiding this comment.
I was planning on adding a few more flags, e.g. DelayedInitialization for ControlProxy objects that are created before the actual CO (e.g. [AutoDJ],enabled). Right now we just disable the warnings completely, but IMHO this is not a good solution.
There was a problem hiding this comment.
Why not WarnIfMissing and WarnAndAssertIfMissing?
I wanted to make it explicit from the caller side that the warnings/assertions are disabled, so that don't set InitializeLater and accidently disable warnings/assertions because you forgot to OR this with the WarnAndAssertIfMissing flag.
Btw, I also had to add a flag to allow missing keys for WWidgetStack (which takes params from skins).
|
Renamed the PR to better reflect the intention. |
|
I hope everything is in order now. I feel like our CO stuff could use some refactoring, e.g. the skin system uses |
|
Instead of Implicit disable warnings, we can introduce another function that is called getOrCreateControl() or something and maybe tryGetControl() |
|
Is this really a 2.3 PR? This is not without a risk. |
I think it makes sense. It adds additional safety and the additional debug assertions will be disabled in release builds anyway. |
|
uklotzde
left a comment
There was a problem hiding this comment.
master: Multiple debug assertions while starting Mixxx
You mean you pulled this branch into master? |
Yes, my regular development version is based on master. |
|
I suppose this might be caused by the controller engine changes from #2682. Does this PR (based on 2.3) work for you? |
|
Reminder for later: The changes in Remaining debug assertions in master on startup: These have to be fixed in time if we decide to merge this PR. Otherwise starting Mixxx with development settings in master becomes annoying. I assume that these assertions do not appear in 2.3 if you tested it. No need to recompile everything twice locally. But we need to have a plan how to fix those in master. |
|
@daschuer Merge? |
|
Let me recheck this first, I'll make sure that none of the assertions from master are already present here. I could be that these assertions just don't fire because skin is not lacking a CO. |
|
The flaky test strikes again: can't we call mixxx-test instead of ctest? |
|
The rest LGTM, Thank you. |
|
The |
|
Yes ControlObject::getOrCreateControl(key) would be much better express the intent. |
|
Oh sorry, scratch that. I am fine with the current solution. It is performs good and is easy to understand. |
|
Ok, then it's ready to merge now. |
|
Thank you for taking care if this. |
|
After merging 2.3 into master many tests trigger debug assertions: Example: |
|
See #2910. |
This should prevent CO failures from going unnoticed. Right now, only a warning is displayed in the log, which can easily be overlooked.
Zulip discussion that prompted this PR: https://mixxx.zulipchat.com/#narrow/stream/109171-development/topic/Macros.2FSaved.20Hotcue.20Routines.2F.22Serato.20Flip.22/near/201478587