From 9f40d6c2516c54e730b52b7326287ddbb603ab5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Karla=C5=A1?= Date: Fri, 12 Feb 2016 18:23:21 +0100 Subject: [PATCH] Fixed memory leaks caused by sinking everything Sinking is done when object is attached to parent... Sinking everything when Raw is set results into incrementing ref count for no reason, hence memory leak... g_object_ref and g_object_unref is just so random code that is not even worth explaining why it's deleted --- glib/Object.cs | 3 --- glib/ToggleRef.cs | 1 - gtk/Object.custom | 5 ----- 3 files changed, 9 deletions(-) diff --git a/glib/Object.cs b/glib/Object.cs index d600fd95f..670dfba7b 100644 --- a/glib/Object.cs +++ b/glib/Object.cs @@ -134,9 +134,6 @@ public static Object GetObject(IntPtr o, bool owned_ref) return obj; } - if (!owned_ref) - g_object_ref (o); - obj = GLib.ObjectManager.CreateObject(o); } if (obj == null) { diff --git a/glib/ToggleRef.cs b/glib/ToggleRef.cs index a80567cde..a3d0a8be9 100644 --- a/glib/ToggleRef.cs +++ b/glib/ToggleRef.cs @@ -39,7 +39,6 @@ public ToggleRef (GLib.Object target) gch = GCHandle.Alloc (this); reference = target; g_object_add_toggle_ref (target.Handle, ToggleNotifyCallback, (IntPtr) gch); - g_object_unref (target.Handle); } public bool IsAlive { diff --git a/gtk/Object.custom b/gtk/Object.custom index 14aacc24b..44c101200 100644 --- a/gtk/Object.custom +++ b/gtk/Object.custom @@ -105,16 +105,11 @@ base.Dispose (); } - [DllImport("libgobject-2.0-0.dll", CallingConvention=CallingConvention.Cdecl)] - private static extern void g_object_ref_sink (IntPtr raw); - protected override IntPtr Raw { get { return base.Raw; } set { - if (value != IntPtr.Zero) - g_object_ref_sink (value); base.Raw = value; if (value != IntPtr.Zero) InternalDestroyed += NativeDestroyHandler;