GLibSharp / GtkSharp

.Net bindings for gtk+3 and above
Other
27 stars 21 forks source link

GLib.Opaque: Drop extra reference when object is un-owned before dispose #51

Open xhaakon opened 4 years ago

xhaakon commented 4 years ago

If the Owned property of a Gst.MiniObject (base class Opaque) is set from true to false during its lifetime, its reference count is not decremented.

For example when Gst.Event (derived from Gst.MiniObject) is created using Gst.Event.NewEos(), Gst.MiniObject.Ref() increments its ref count and sets Owned = true. Then, passing the event to Gst.Pad.PushEvent(), sets Owned = false, but this change won't remove the extra reference that MiniObject.Ref() added earlier and it won't get cleared even when Unref() gets eventualy called from Dispose(), because Gst.MiniObject.Unref() only decrements ref count of objects that are Owned.

This change Unref()s the object when Owned property gets set to false.