johnfactotum / foliate

Read e-books in style
https://johnfactotum.github.io/foliate/
GNU General Public License v3.0
6.15k stars 283 forks source link

Memory leaks #1106

Open johnfactotum opened 10 months ago

johnfactotum commented 10 months ago

Describe the bug Many widgets in Foliate are leaking.

To Reproduce

  1. Run Foliate with GOBJECT_DEBUG=instance-count
  2. Open GTK inspector
  3. Open and close books multiple times
  4. See that, for many objects, the count never decreases

Expected behavior It should not leak.

Version:

Additional context Currently it calls run_dispose() for the WebView. But for everything else, if there's ever a signal connection or something, the object will never get disposed.

To fix this I think it should disconnect everything in vfunc_unroot(). But that's terribly inconvenient. It seems that GJS is getting a connect_object method. So probably can just use that.