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

try_remove () may return true when nothing is removed #103

Closed
BrainBlasted opened this issue Feb 2, 2022 · 3 comments
Closed

try_remove () may return true when nothing is removed #103

BrainBlasted opened this issue Feb 2, 2022 · 3 comments

Comments

@BrainBlasted
Copy link

WidgetPlus::try_remove() may return true when nothing is removed. It only checks that self is one of a set number of supported widgets, and then calls the appropriate remove() function. However, there are no guarantees that the child is actually removed. Each of these APIs are a no-op when you pass a widget that's not one of their children, and it's still possible to do that with try_remove().

@AaronErhardt
Copy link
Member

Thanks for pointing this out!

I wonder, is there a way to fix this? Maybe with something like widget.parent() == self you could find out whether the remove will actually work. Otherwise I will update the docs to describe the behavior correctly.

@BrainBlasted
Copy link
Author

widget.parent() isn't reliable, because there can be widgets between the "container" and the "child". For example, GtkHeaderBar contains multiple GtkBoxes that it puts the start, end, and center children in. widget.parent() on one of the children would return a box instead of the GtkHeaderBar.

@AaronErhardt
Copy link
Member

I've updated the docs. And this will be likely replaced by something more robust in the next major release.

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

No branches or pull requests

2 participants