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

Disconnect controller qt connections #4476

Merged
merged 5 commits into from
Nov 5, 2021

Conversation

ywwg
Copy link
Member

@ywwg ywwg commented Oct 23, 2021

Disconnect connections from controllers when deleting controller prefs

Leaving the stale connections can cause segfaults on exit.

This should fix https://bugs.launchpad.net/mixxx/+bug/1946581

@ywwg ywwg changed the title Disconnect controllers Disconnect controller qt connections Oct 23, 2021
Comment on lines 174 to 182
connect(pController,
m_controllerConnections.append(connect(pController,
&Controller::openChanged,
[this, pControllerDlg](bool bOpen) {
slotHighlightDevice(pControllerDlg, bOpen);
});
}));
Copy link
Member

Choose a reason for hiding this comment

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

I think we should always pass a context object as third parameter (this).

If we do that we can probably get rid of the list, and just call disconnect(pController, nullptr, this, nullptr) to remove all connections between a controller and the dialog.

Copy link
Member Author

Choose a reason for hiding this comment

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

I did that at first, but I was worried that the call to enumerate the list of controllers would be incorrect at the time of destruction. And since disconnect requires the sender object to be specified, we need to make sure that list is complete. What do you think?

Copy link
Member Author

Choose a reason for hiding this comment

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

hm so it looks like because we don't do hotplug, updateControllerList is only called once, so the list of controllers should be static. However once we go to hotplug, we will have big problems with inconsistency between dlgprefcontrollers and the controllermanager. (And these inconsistencies could easily cause crashes). For now, I'll eliminate the list and trust the the controller list doesn't change.

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated. This is safe code for now, but may not be in the future. Added some comments as hints to future developers trying to add hotplug so they don't trip over this code. (There is no way to write this code currently that would be future-proof)

Copy link
Member Author

@ywwg ywwg Oct 25, 2021

Choose a reason for hiding this comment

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

oh I understand your comment now. I don't know how to do what you describe though.

Copy link
Member Author

Choose a reason for hiding this comment

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

ahhh I figured out which third parameter you meant. got it

…to disconnect

This is safe code for now, but may not be in the future. Added some comments as hints to future developers trying to add hotplug so they don't trip over this code.  (There is no way to write this code currently that would be future-proof)
@ywwg ywwg requested a review from Holzhaus October 25, 2021 21:17
Copy link
Member

@Holzhaus Holzhaus left a comment

Choose a reason for hiding this comment

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

LGTM, thank you.

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.

2 participants