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

Fix improperly exclusive radio buttons #10423

Merged

Conversation

Pokechu22
Copy link
Contributor

QRadioButton has an autoExclusive function, but it only works if the buttons share the same parent widget. QButtonGroup can be used to manually specify groups.

Example of the problem

Open the breakpoints tab by selecting View → Breakpoints (the debugging UI may need to be enabled). Then, while a game is running, select "New". Then, click on the "Memory breakpoint" button 4 times. Weird stuff happens.

image
image
image
image
image

I'm not 100% sure that this doesn't leak memory; the documentation isn't explicit about what owns the QButtonGroup object (to my understanding, Qt normally manages deletion of objects, but I don't know if it'll follow the addButton chain backwards). We already use it this way in CheatSearchFactoryWidget.cpp though.

@Pokechu22 Pokechu22 force-pushed the improperly-exclusive-radio-buttons branch from 8b1f56f to e50c32c Compare February 8, 2022 20:24
@JosJuice
Copy link
Member

I'm not 100% sure that this doesn't leak memory; the documentation isn't explicit about what owns the QButtonGroup object (to my understanding, Qt normally manages deletion of objects, but I don't know if it'll follow the addButton chain backwards). We already use it this way in CheatSearchFactoryWidget.cpp though.

Absent any explicit documentation, I would assume it works the way QObjects work in general: They're deleted when the parent is deleted. So I would suggest setting a parent for them.

@Pokechu22 Pokechu22 force-pushed the improperly-exclusive-radio-buttons branch from e50c32c to f2f9df7 Compare February 12, 2022 19:45
Copy link
Contributor

@Dentomologist Dentomologist left a comment

Choose a reason for hiding this comment

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

LGTM, no blocking issues.

  • [Nitpicky] The QButtonGroup pointers could be auto* const.

@Pokechu22
Copy link
Contributor Author

Very little of the existing DolphinQt code uses auto* const, so I'm not going to worry about that for now.

@JosJuice JosJuice merged commit 9ebfdff into dolphin-emu:master Feb 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants