mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-17 03:35:21 +00:00
gst/gstbin.c: Can't use GPOINTER_TO_INT and GINT_TO_POINTER with GTypes.
Original commit message from CVS: * gst/gstbin.c: (compare_interface), (gst_bin_get_by_interface), (gst_bin_iterate_all_by_interface): Can't use GPOINTER_TO_INT and GINT_TO_POINTER with GTypes. GTypes are gulongs and thus the top 4 bytes might be cut off on some platforms when doing GPOINTER_TO_INT, leading to invalid GTypes and bad things happening. Also add a check to make sure the type passed in is really an interface type.
This commit is contained in:
parent
a55b4bf721
commit
99f16655f4
2 changed files with 18 additions and 4 deletions
11
ChangeLog
11
ChangeLog
|
@ -1,3 +1,14 @@
|
|||
2006-07-07 Tim-Philipp Müller <tim at centricular dot net>
|
||||
|
||||
* gst/gstbin.c: (compare_interface), (gst_bin_get_by_interface),
|
||||
(gst_bin_iterate_all_by_interface):
|
||||
Can't use GPOINTER_TO_INT and GINT_TO_POINTER with GTypes.
|
||||
GTypes are gulongs and thus the top 4 bytes might be cut
|
||||
off on some platforms when doing GPOINTER_TO_INT, leading
|
||||
to invalid GTypes and bad things happening.
|
||||
Also add a check to make sure the type passed in is really
|
||||
an interface type.
|
||||
|
||||
2006-07-07 Tim-Philipp Müller <tim at centricular dot net>
|
||||
|
||||
* .cvsignore:
|
||||
|
|
11
gst/gstbin.c
11
gst/gstbin.c
|
@ -2516,9 +2516,10 @@ gst_bin_get_by_name_recurse_up (GstBin * bin, const gchar * name)
|
|||
static gint
|
||||
compare_interface (GstElement * element, gpointer interface)
|
||||
{
|
||||
GType interface_type = (GType) interface;
|
||||
gint ret;
|
||||
|
||||
if (G_TYPE_CHECK_INSTANCE_TYPE (element, GPOINTER_TO_INT (interface))) {
|
||||
if (G_TYPE_CHECK_INSTANCE_TYPE (element, interface_type)) {
|
||||
ret = 0;
|
||||
} else {
|
||||
/* we did not find the element, need to release the ref
|
||||
|
@ -2548,13 +2549,14 @@ GstElement *
|
|||
gst_bin_get_by_interface (GstBin * bin, GType interface)
|
||||
{
|
||||
GstIterator *children;
|
||||
GstIterator *result;
|
||||
gpointer result;
|
||||
|
||||
g_return_val_if_fail (GST_IS_BIN (bin), NULL);
|
||||
g_return_val_if_fail (G_TYPE_IS_INTERFACE (interface), NULL);
|
||||
|
||||
children = gst_bin_iterate_recurse (bin);
|
||||
result = gst_iterator_find_custom (children, (GCompareFunc) compare_interface,
|
||||
GINT_TO_POINTER (interface));
|
||||
(gpointer) interface);
|
||||
gst_iterator_free (children);
|
||||
|
||||
return GST_ELEMENT_CAST (result);
|
||||
|
@ -2585,10 +2587,11 @@ gst_bin_iterate_all_by_interface (GstBin * bin, GType interface)
|
|||
GstIterator *result;
|
||||
|
||||
g_return_val_if_fail (GST_IS_BIN (bin), NULL);
|
||||
g_return_val_if_fail (G_TYPE_IS_INTERFACE (interface), NULL);
|
||||
|
||||
children = gst_bin_iterate_recurse (bin);
|
||||
result = gst_iterator_filter (children, (GCompareFunc) compare_interface,
|
||||
GINT_TO_POINTER (interface));
|
||||
(gpointer) interface);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue