Skip to content

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

Open
xhaakon wants to merge 1 commit into
GLibSharp:masterfrom
xhaakon:fix-ref-leak-opaque-owned
Open

GLib.Opaque: Drop extra reference when object is un-owned before dispose#51
xhaakon wants to merge 1 commit into
GLibSharp:masterfrom
xhaakon:fix-ref-leak-opaque-owned

Conversation

@xhaakon

@xhaakon xhaakon commented Aug 11, 2020

Copy link
Copy Markdown
Contributor

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.

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.
@xhaakon xhaakon force-pushed the fix-ref-leak-opaque-owned branch from c18ed8f to f47b66b Compare August 11, 2020 14:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants