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 662664 - API: add gst_element_class_add_static_pad_template() and fix template pad ref leaks
API: add gst_element_class_add_static_pad_template() and fix template pad ref...
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gstreamer (core)
git master
Other Linux
: Normal normal
: 0.10.36
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2011-10-25 10:21 UTC by Vincent Penquerc'h
Modified: 2011-11-28 17:04 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
gstelement: add gst_element_class_add_pad_template_from_static (2.21 KB, patch)
2011-10-25 10:21 UTC, Vincent Penquerc'h
none Details | Review
various: fix pad template leaks (15.86 KB, patch)
2011-10-25 10:21 UTC, Vincent Penquerc'h
none Details | Review
various: fix pad template leaks (59.93 KB, patch)
2011-10-25 10:22 UTC, Vincent Penquerc'h
committed Details | Review
various: fix pad template leaks (202.31 KB, patch)
2011-10-25 10:22 UTC, Vincent Penquerc'h
committed Details | Review
various: fix pad template ref leaks (246.69 KB, patch)
2011-10-25 10:22 UTC, Vincent Penquerc'h
committed Details | Review
various: fix pad template ref leaks (26.92 KB, patch)
2011-10-25 10:22 UTC, Vincent Penquerc'h
committed Details | Review
ffmpeg: fix pad template ref leaks (5.76 KB, patch)
2011-10-25 10:22 UTC, Vincent Penquerc'h
committed Details | Review
various: fix pad template leaks (15.87 KB, patch)
2011-10-25 12:06 UTC, Vincent Penquerc'h
committed Details | Review
gstelement: add gst_element_class_add_pad_template_from_static (2.72 KB, patch)
2011-10-25 12:27 UTC, Vincent Penquerc'h
committed Details | Review

Description Vincent Penquerc'h 2011-10-25 10:21:15 UTC
Plenty of cut and pasted code pass a pad template ref to a function that does not take the ref, without unreffing the pad template afterwards (though a few do).

The patches below touch a huge amount of files, but the alternatives seem unworkable (_add_pad_template has to take a ref, from a comment within, and gst_static_pad_template_get has to return a ref).

Note that the cleanup function in gstelement.c does not seem to be called, so that ref taken by _add_pad_template isn't released, causing the object not actually be unreffed, so this needs looking at too (though some people may look at this as not-a-real-leak as it's called once per class and not once per object).

One patch for the API addition, then one patch per repo to use it.
Comment 1 Vincent Penquerc'h 2011-10-25 10:21:44 UTC
Created attachment 199911 [details] [review]
gstelement: add gst_element_class_add_pad_template_from_static

This function helps ensure the pad template is unreffed
without having to complicate the calling code.
Comment 2 Vincent Penquerc'h 2011-10-25 10:21:52 UTC
Created attachment 199912 [details] [review]
various: fix pad template leaks
Comment 3 Vincent Penquerc'h 2011-10-25 10:22:04 UTC
Created attachment 199913 [details] [review]
various: fix pad template leaks
Comment 4 Vincent Penquerc'h 2011-10-25 10:22:15 UTC
Created attachment 199914 [details] [review]
various: fix pad template leaks
Comment 5 Vincent Penquerc'h 2011-10-25 10:22:29 UTC
Created attachment 199915 [details] [review]
various: fix pad template ref leaks
Comment 6 Vincent Penquerc'h 2011-10-25 10:22:37 UTC
Created attachment 199916 [details] [review]
various: fix pad template ref leaks
Comment 7 Vincent Penquerc'h 2011-10-25 10:22:44 UTC
Created attachment 199917 [details] [review]
ffmpeg: fix pad template ref leaks
Comment 8 Vincent Penquerc'h 2011-10-25 12:06:29 UTC
Created attachment 199921 [details] [review]
various: fix pad template leaks
Comment 9 Vincent Penquerc'h 2011-10-25 12:27:17 UTC
Created attachment 199923 [details] [review]
gstelement: add gst_element_class_add_pad_template_from_static

This function helps ensure the pad template is unreffed
without having to complicate the calling code.

(add the new function to the def file)
Comment 10 Sebastian Dröge (slomo) 2011-11-24 09:32:11 UTC
Makes sense but please also merge this in 0.11 when pushing. Might be unnecessary with 0.11 because reference handling in that area changed IIRC, please check that.
Comment 11 Stefan Sauer (gstreamer, gtkdoc dev) 2011-11-28 08:47:23 UTC
Vincent, it would be great to get these in before the freeze.
Comment 12 Tim-Philipp Müller 2011-11-28 10:31:26 UTC
Sorry for the bikeshedding, but why add_pad_template_from_static() and not just _add_static_pad_template()?
Comment 13 Vincent Penquerc'h 2011-11-28 11:58:57 UTC
Because it's a copy of _add_pad_template, which takes a static template as paramter directly. The other name makes sense too I suppose. I'm going to merge this today, and don't care which name to use, so just confirm quick which you'd rather.
Comment 14 Vincent Penquerc'h 2011-11-28 13:44:48 UTC
Committed with tpm's name change suggestion.
In 0.11, the code seems to not need this indeed, it takes ownership of the floating ref. While I'm not fluent in ref language, I think this makes the patch unneeded for 0.11.
Comment 15 Sebastian Dröge (slomo) 2011-11-28 17:04:55 UTC
Yes, in 0.11 it takes ownership and ref_sink() the static pad template, to be consistent with other _add() API like gst_bin_add(). This change is not necessary in 0.11