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

feat(Views): stop disposing #946

Merged
merged 5 commits into from
May 16, 2024
Merged

feat(Views): stop disposing #946

merged 5 commits into from
May 16, 2024

Conversation

GeopJr
Copy link
Owner

@GeopJr GeopJr commented May 16, 2024

This should fix all the random segfaults

Why were we disposing?

Ref cycles would prevent Views from being destroyed. They would drop from ~60 to ~50 refs. That would also prevent websockets from closing.

Disposing unrefs everything, allowing them to be freed from memory however that had the cost of... losing reference to them and their children sometimes.

Now what?

After some debugging, I pinned it down to Gtk.ListBox#bind_model. We have to clear the binding when it's time to be disposed, but there's no appropriate stage to do that on as dispose or destroy won't ever be called because of it.

Instead, manually remove the binding when it's time to be disposed, by using the same hack as before. The difference now is that we gracefully allow the view and its children to be destroyed, giving also the chance to notice and debug memory leaks.

Why keep the hack?

I believe the current choices are:

  1. Keep the hack but manually clear the binding (this PR)*
  2. Remove the hack but stop using Gtk.ListBox#bind_model

I don't want to do (2), at least not right now. Exposing just the model and letting descendants to just add items to it, rather than overriding a bunch of methods.

* Another possibility would be to clear it when removing the pages, but... that's not always possible as we have to keep track of navigation view replacements and nested views

@GeopJr GeopJr merged commit c75b812 into main May 16, 2024
5 checks passed
@GeopJr GeopJr deleted the feat/goodbye-dispose branch May 16, 2024 15:25
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.

1 participant