From 99f16655f4cfbc8e06b5972417ba11279083a64e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim-Philipp=20M=C3=BCller?= Date: Fri, 7 Jul 2006 15:42:08 +0000 Subject: [PATCH] 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. --- ChangeLog | 11 +++++++++++ gst/gstbin.c | 11 +++++++---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 632ba0b..807dc91 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,16 @@ 2006-07-07 Tim-Philipp Müller + * 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 + * .cvsignore: Ignore more. diff --git a/gst/gstbin.c b/gst/gstbin.c index 38c41b3..32c0d12 100644 --- a/gst/gstbin.c +++ b/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; } -- 2.7.4