From cff0582d61fab4ce8983b7706b5262abd0489af8 Mon Sep 17 00:00:00 2001 From: Master T Date: Thu, 18 Sep 2014 04:59:33 +0200 Subject: [PATCH] MiniObject: fix MakeWritable In case the MiniObject had a reference count of 1 (writable), the object was destroyed due to a bug in Opaque not handling self-assignment of Raw. In case the MiniObject was not writable, the returned copy was not writable either because it had two references: one from gst_mini_object_make_writable and one from Opaque.Raw. --- sources/custom/MiniObject.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/sources/custom/MiniObject.cs b/sources/custom/MiniObject.cs index 3187bdee47..7b87b43acc 100644 --- a/sources/custom/MiniObject.cs +++ b/sources/custom/MiniObject.cs @@ -46,9 +46,12 @@ namespace Gst { static extern IntPtr gst_mini_object_make_writable(IntPtr mini_object); public void MakeWritable() { - Console.WriteLine (Handle); - Raw = gst_mini_object_make_writable (Raw); - Console.WriteLine (Handle); + IntPtr raw = gst_mini_object_make_writable (Raw); + if (raw == Raw) + return; + Raw = raw; + if (raw != IntPtr.Zero) + Unref (raw); } } }