[mono/gtk-sharp] [2 commits] 41eeecbf: cairo: fix leak when Context object is finalized
| Newsgroups | gmane.comp.gnome.mono.patches |
|---|---|
| Message-ID | <000001421eb55a67-5bd23a88-dc1c-440b-998a-a129ebc3c60d-000000@email.amazonses.com> |
Branch: refs/heads/master
Home: https://github.com/mono/gtk-sharp
Compare: https://github.com/mono/gtk-sharp/compare/fc9746013d78...29674827628e
Commit: 41eeecbf9a6d84fa29ccee9adfee98ada1f1de66
Author: Andrés G. Aragoneses <[email protected]> (knocte)
Committer: Bertrand Lorentz <[email protected]> (bl8)
Date: 2013-11-03 14:21:49 GMT
URL: https://github.com/mono/gtk-sharp/commit/41eeecbf9a6d84fa29ccee9adfee98ada1f1de66
cairo: fix leak when Context object is finalized
When the finalizer calls Dispose(), disposing is false, it means that
CairoDebug traces should be printed, but the reference count on the
native context should still be decreased. Otherwise a real leak
would appear, as the native context would never be freed when the
managed object is GCed.
Changed paths:
M cairo/Context.cs
Modified: cairo/Context.cs
===================================================================
@@ -115,7 +115,7 @@ protected virtual void Dispose (bool disposing)
if (!disposing || CairoDebug.Enabled)
CairoDebug.OnDisposed<Context> (handle, disposing);
- if (!disposing || handle == IntPtr.Zero)
+ if (handle == IntPtr.Zero)
return;
NativeMethods.cairo_destroy (handle);
Commit: 29674827628e4e4cfb4426cd110b1e348465ddfe
Author: Andrés G. Aragoneses <[email protected]> (knocte)
Committer: Bertrand Lorentz <[email protected]> (bl8)
Date: 2013-11-03 16:01:34 GMT
URL: https://github.com/mono/gtk-sharp/commit/29674827628e4e4cfb4426cd110b1e348465ddfe
Revert "gtk: Mark the Cairo.Context in Widget.Drawn as owned"
This reverts commit 21bfaa7a9d84218e01529a7b9af28085f6e68306.
After fixing the memory leak when finalizing a Context object in the
previous commit, native crashes would happen when using a Gtk#-based
app. The reason is that this commit tried to fix the leak with the wrong
approach of marking the CairoContext as owned. This avoided the leak by
not incrementing the reference count, but now that the leak is fixed,
cairo_destroy is called one time too much.
The CairoContext passed in the Draw signal is not marked as
transfer-ownership=full in GObject-Introspection metadata. So unmarking
this as owned fixes the "potential double-free" assertion that was
causing the crash.
Changed paths:
M gtk/Gtk.metadata
Modified: gtk/Gtk.metadata
===================================================================
@@ -863,7 +863,6 @@
<attr path="/api/namespace/object[@cname='GtkWidget']/signal[@name='Destroy']" name="hidden">1</attr>
<attr path="/api/namespace/object[@cname='GtkWidget']/signal[@name='Draw']" name="name">Drawn</attr>
<attr path="/api/namespace/object[@cname='GtkWidget']/signal[@cname='draw']" name="manual">true</attr>
- <attr path="/api/namespace/object[@cname='GtkWidget']/signal[@cname='draw']/*/*[@name='cr']" name="owned">true</attr>
<attr path="/api/namespace/object[@cname='GtkWidget']/signal[@name='Event']" name="name">WidgetEvent</attr>
<attr path="/api/namespace/object[@cname='GtkWidget']/signal[@name='EventAfter']/*/*[@name='p0']" name="name">event</attr>
<attr path="/api/namespace/object[@cname='GtkWidget']/signal[@name='EventAfter']" name="name">WidgetEventAfter</attr>
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches