Skip to content

Commit

Permalink
Fixed memory leaks caused by sinking everything
Browse files Browse the repository at this point in the history
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
  • Loading branch information
David Karlaš committed Feb 12, 2016
1 parent eb3ef5f commit 9f40d6c
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 9 deletions.
3 changes: 0 additions & 3 deletions glib/Object.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
1 change: 0 additions & 1 deletion glib/ToggleRef.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 0 additions & 5 deletions gtk/Object.custom
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 9f40d6c

Please sign in to comment.