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

remove LegacyControllerMappingVisitor #3635

Merged
merged 1 commit into from
Feb 15, 2021

Conversation

Be-ing
Copy link
Contributor

@Be-ing Be-ing commented Feb 15, 2021

This class increased coupling and made the code very confusing for
no benefit.

@Be-ing Be-ing marked this pull request as draft February 15, 2021 12:56
@Be-ing Be-ing force-pushed the remove_legacycontrollermappingvisitor branch from 6b13f08 to 97179ac Compare February 15, 2021 13:02
@Be-ing Be-ing marked this pull request as ready for review February 15, 2021 13:02
// This immediately calls one of the two visit() methods below.
m_pMapping->accept(this);
m_pMidiMapping = dynamic_cast<LegacyMidiControllerMapping*>(pMapping.data());
if (!m_pMidiMapping) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this become VERIFY_OR_DEBUG_ASSERT? Otherwise please add a short comment that silently ignoring any other derived type here and resetting the member to nullptr when the dynamic cast fails is intended.

If the setMapping() is called twice first with the expected type (Midi) and then with another type (Hid) the internal pointer would be reset and the first invocation would get lost.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried that initially but was asserting even though everything was working fine. A check could be added to the calling code to avoid that, but I'm trying to keep the changes as minimal as possible for now.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's fine. Just write a short comment about what you know. This knowledge might be helpful in the future.

The code looks suspicious to me without knowing the context or history. Usually you take a different route if a dynamic_cast fails. Here you (re-)set the member unconditionally before aborting.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I added a comment. I may implement that debug assertion later after cleaning up more code. We'll see. First I need to clear the road before I can see the paths ahead.

This class increased coupling and made the code very confusing for
no benefit.
@Be-ing Be-ing force-pushed the remove_legacycontrollermappingvisitor branch from 97179ac to 5421a3d Compare February 15, 2021 17:58
@Be-ing
Copy link
Contributor Author

Be-ing commented Feb 15, 2021

merge?

Copy link
Contributor

@uklotzde uklotzde left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@uklotzde uklotzde merged commit 6471e17 into mixxxdj:main Feb 15, 2021
@Be-ing Be-ing deleted the remove_legacycontrollermappingvisitor branch February 15, 2021 18:53
@Be-ing
Copy link
Contributor Author

Be-ing commented Feb 15, 2021

Thank you for the quick review. I will remove ConstLegacyControllerMappingVisitor next.

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

2 participants