gtk-sharp
gtk-sharp copied to clipboard
cairo: fix remaining leaks when finalizer gets called
Apply same finalizer leak fix to the rest of IDisposable-ownership cairo classes as the one recently committed for Cairo.Context[1].
[1] https://github.com/mono/gtk-sharp/commit/41eeecbf9a6d84fa29ccee9adfee98ada1f1de66
@bl8 I pushed to this PR the extra commit with the fixes I told you yesterday, it's very important that this (or a similar approach to respect the rule "Don't try to use Cairo in threads other than the main (Gdk) thread." mentioned in http://www.mono-project.com/Mono.Cairo) gets committed before the 2.99.2 release IMO. I know that maybe cairo-sharp should not depend on glib-sharp because there is no technical reason for it, but native cairo already has an optional dependency on native glib, so I don't think the dependency at the binding level is that bad.
I built gtk-sharp from the latest git master with your commit c28b352 (cairo: fix remainind leaks) applied on top, and I tried running Banshee git master. I didn't see any crashes or freezes. Could you try to reproduce those issues and provide some stacktraces or any info you have ?
Make sure you use the latest gtk-sharp from git master, I've just fixed another leak in the Widget.Drawn signal.
@bl8, take in account that with your fixes in https://github.com/mono/gtk-sharp/commit/e48ac63d54c4c245f25b73c548f90b649acea2c8 and https://github.com/mono/gtk-sharp/commit/51f102bc34de812843d37b3eab3b556583550b50 the freezes and hangs are much more difficult to reproduce (because in this case it's not the GC calling the destroy() method), so after I reverted those two commits, I could reproduce two problems which I pasted here: https://bugzilla.xamarin.com/show_bug.cgi?id=16321
If I try a bit harder, it's possible that I'll reproduce the 3rd problem I also experienced: a X-Windows crash (BadMatch error, I think).
So, just to make it doubly clear: the fact that your commits e48ac63 and 51f102b make this problem much harder to reproduce (or impossible to reproduce with banshee maybe) doesn't mean that the bug doesn't exist, because other people's code (instead of the generated code) may also forget to call Dispose(), which then means the finalizer would act, which means that the sentence "Don't try to use Cairo in threads other than the main (Gdk) thread." (from http://www.mono-project.com/Mono.Cairo) is not respected, which brings all sorts of problems (in the same way if you forget to call Gtk from the proper thread).
I've pushed the first commit ("fix remaining leaks...") to git master. Let's see if it causes any issues for people, I haven't seen any on my side.