From db1d99db76379e8bceb26fcee951822fd5e1819b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= Date: Sat, 20 Jan 2018 15:30:53 +0000 Subject: [PATCH] childproxy: gracefully handle methods being NULL Do this for all method invoke functions for consistency. https://bugzilla.gnome.org/show_bug.cgi?id=750154 --- gst/gstchildproxy.c | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/gst/gstchildproxy.c b/gst/gstchildproxy.c index c8581a2ee9..ca5e47ea33 100644 --- a/gst/gstchildproxy.c +++ b/gst/gstchildproxy.c @@ -117,10 +117,16 @@ gst_child_proxy_default_get_child_by_name (GstChildProxy * parent, GObject * gst_child_proxy_get_child_by_name (GstChildProxy * parent, const gchar * name) { + GstChildProxyInterface *iface; + g_return_val_if_fail (GST_IS_CHILD_PROXY (parent), 0); - return (GST_CHILD_PROXY_GET_INTERFACE (parent)->get_child_by_name (parent, - name)); + iface = GST_CHILD_PROXY_GET_INTERFACE (parent); + + if (iface->get_child_by_name != NULL) + return iface->get_child_by_name (parent, name); + + return NULL; } /** @@ -138,10 +144,16 @@ gst_child_proxy_get_child_by_name (GstChildProxy * parent, const gchar * name) GObject * gst_child_proxy_get_child_by_index (GstChildProxy * parent, guint index) { + GstChildProxyInterface *iface; + g_return_val_if_fail (GST_IS_CHILD_PROXY (parent), NULL); - return (GST_CHILD_PROXY_GET_INTERFACE (parent)->get_child_by_index (parent, - index)); + iface = GST_CHILD_PROXY_GET_INTERFACE (parent); + + if (iface->get_child_by_index != NULL) + return iface->get_child_by_index (parent, index); + + return NULL; } /** @@ -157,9 +169,16 @@ gst_child_proxy_get_child_by_index (GstChildProxy * parent, guint index) guint gst_child_proxy_get_children_count (GstChildProxy * parent) { + GstChildProxyInterface *iface; + g_return_val_if_fail (GST_IS_CHILD_PROXY (parent), 0); - return (GST_CHILD_PROXY_GET_INTERFACE (parent)->get_children_count (parent)); + iface = GST_CHILD_PROXY_GET_INTERFACE (parent); + + if (iface->get_children_count != NULL) + return iface->get_children_count (parent); + + return 0; } /**