controlbinding: error handling for binding controlsources to wrong properties
authorStefan Sauer <ensonic@users.sf.net>
Fri, 8 Feb 2013 20:21:48 +0000 (21:21 +0100)
committerStefan Sauer <ensonic@users.sf.net>
Fri, 8 Feb 2013 20:38:22 +0000 (21:38 +0100)
Add warning if property is not suitable for controlling. When adding a control-
binding check that pspec!=NULL.

gst/gstcontrolbinding.c
gst/gstobject.c
libs/gst/controller/gstdirectcontrolbinding.c

index 3868dc7..4f071e4 100644 (file)
@@ -135,6 +135,11 @@ gst_control_binding_constructor (GType type, guint n_construct_params,
                 G_PARAM_CONSTRUCT_ONLY)) ==
         (G_PARAM_WRITABLE | GST_PARAM_CONTROLLABLE)) {
       binding->pspec = pspec;
+    } else {
+      GST_WARNING_OBJECT (binding->object,
+          "property '%s' on class '%s' needs to "
+          "be writeable, controlable and not construct_only", binding->name,
+          G_OBJECT_TYPE_NAME (binding->object));
     }
   } else {
     GST_WARNING_OBJECT (binding->object, "class '%s' has no property '%s'",
index 1e2c941..d177ef3 100644 (file)
@@ -1162,12 +1162,13 @@ gst_object_set_control_binding_disabled (GstObject * object,
  * @object: the controller object
  * @binding: (transfer full): the #GstControlBinding that should be used
  *
- * Sets the #GstControlBinding. If there already was a #GstControlBinding
- * for this property it will be replaced.
+ * Attach the #GstControlBinding to the object. If there already was a
+ * #GstControlBinding for this property it will be replaced.
+ *
  * The @object will take ownership of the @binding.
  *
- * Returns: %FALSE if the given @binding has not been setup for this object  or
- * %TRUE otherwise.
+ * Returns: %FALSE if the given @binding has not been setup for this object or
+ * has been setup for a non suitable property, %TRUE otherwise.
  */
 gboolean
 gst_object_add_control_binding (GstObject * object, GstControlBinding * binding)
@@ -1176,6 +1177,7 @@ gst_object_add_control_binding (GstObject * object, GstControlBinding * binding)
 
   g_return_val_if_fail (GST_IS_OBJECT (object), FALSE);
   g_return_val_if_fail (GST_IS_CONTROL_BINDING (binding), FALSE);
+  g_return_val_if_fail (binding->pspec, FALSE);
 
   GST_OBJECT_LOCK (object);
   if ((old = gst_object_find_control_binding (object, binding->name))) {
index 7daaed3..5d33e49 100644 (file)
  * @short_description: direct attachment for control sources
  *
  * A value mapping object that attaches control sources to gobject properties. It
- * will map the control values [0.0 ... 1.0] to the target property range. 
+ * will map the control values [0.0 ... 1.0] to the target property range.
  */
 
-
 #include <glib-object.h>
 #include <gst/gst.h>