childproxy: gracefully handle methods being NULL
authorTim-Philipp Müller <tim@centricular.com>
Sat, 20 Jan 2018 15:30:53 +0000 (15:30 +0000)
committerTim-Philipp Müller <tim@centricular.com>
Sat, 20 Jan 2018 15:30:53 +0000 (15:30 +0000)
Do this for all method invoke functions for consistency.

https://bugzilla.gnome.org/show_bug.cgi?id=750154

gst/gstchildproxy.c

index c8581a2..ca5e47e 100644 (file)
@@ -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;
 }
 
 /**