After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 793294 - Add a gst_clear_object (similar to g_clear_object)
Add a gst_clear_object (similar to g_clear_object)
Status: RESOLVED OBSOLETE
Product: GStreamer
Classification: Platform
Component: gstreamer (core)
unspecified
Other Linux
: Normal enhancement
: git master
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2018-02-08 09:47 UTC by Niels De Graef
Modified: 2018-11-03 12:44 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
GstObject: add gst_clear_object() (1.83 KB, patch)
2018-02-08 16:36 UTC, Niels De Graef
none Details | Review

Description Niels De Graef 2018-02-08 09:47:12 UTC
Right now, to unref a GstObject, you have multiple options:

(1) Check for !NULL and use `gst_object_unref`
(2) Use `g_object_unref` -- but this doesn't do any kind refcount logging
(3) Use `g_clear_object` -- but has the same problem as (2)
(4) Use g_clear_pointer with gst_object_unref()

In this bug, I propose a new `gst_clear_object ()` macro, which is analoguous to `g_clear_object` and basically expands to `g_clear_pointer (obj, gst_object_unref)`. That way, we have the advantages of (3) and (4) combined into one.
Comment 1 Sebastian Dröge (slomo) 2018-02-08 13:49:55 UTC
Do you want to provide a patch for this?
Comment 2 Niels De Graef 2018-02-08 16:36:26 UTC
Created attachment 368158 [details] [review]
GstObject: add gst_clear_object()

Disclaimer: I haven't been able to test this (yet). Most of the code is almost identical to the definition of g_clear_object()
Comment 3 Nicolas Dufresne (ndufresne) 2018-02-08 16:47:45 UTC
(In reply to Niels De Graef from comment #0)
> (2) Use `g_object_unref` -- but this doesn't do any kind refcount logging

I think this logging is un-reliable (just think of bindings), so it should not be a good argument to add more API.
Comment 4 Sebastian Dröge (slomo) 2018-02-09 07:45:59 UTC
It's easy enough to add and features we include (the leak tracer) are depending on this, or not?
Comment 5 Niels De Graef 2018-02-09 08:09:04 UTC
(In reply to Sebastian Dröge (slomo) from comment #4)
> It's easy enough to add and features we include (the leak tracer) are
> depending on this, or not?
Yes, it basically falls back to g_object_unref(), so whatever you add/remove there will be executed by gst_clear_object() also.

Just wanted to ask: if this get submitted, would there be interested for similar functions? (e.g. gst_clear_mini_object(), gst_clear_caps(), ...)
Comment 6 Niels De Graef 2018-02-09 08:09:12 UTC
interest*
Comment 7 Niels De Graef 2018-02-09 08:09:45 UTC
and of course it falls back to gst_object_unref(), not g_object_unref().This problem has been fixed in our software repository. The fix will go into the next software release. Once that release is available, you may want to check for a software upgrade provided by your Linux distribution.
Comment 8 Niels De Graef 2018-02-09 08:10:15 UTC
Sorry about the bug change, Friday morning doesn't work too well for me.
Comment 9 Niels De Graef 2018-06-14 14:00:15 UTC
So, does this patch make sense to you guys? :-)
Comment 10 GStreamer system administrator 2018-11-03 12:44:51 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/gstreamer/gstreamer/issues/275.