structured-interface: Properly error out when a child property could not be set
authorThibault Saunier <tsaunier@igalia.com>
Wed, 14 Aug 2019 19:48:46 +0000 (15:48 -0400)
committerThibault Saunier <tsaunier@igalia.com>
Wed, 14 Aug 2019 19:49:20 +0000 (15:49 -0400)
ges/ges-project.c
ges/ges-structured-interface.c

index 6610a5f..35f0efb 100644 (file)
@@ -47,7 +47,7 @@
  * ## Subprojects
  *
  * In order to add a subproject, the only thing to do is to add the subproject
- * with to the main project:
+ * to the main project:
  *
  * ``` c
  * ges_project_add_asset (project, GES_ASSET (subproject));
index 36d9c57..b359774 100644 (file)
@@ -674,11 +674,29 @@ _ges_set_child_property_from_struct (GESTimeline * timeline,
 
   value = gst_structure_get_value (structure, "value");
 
-  GST_DEBUG ("%s Setting %s property to %p",
-      element->name, property_name, value);
+  g_print ("%s Setting %s property to %s\n", element->name, property_name,
+      gst_value_serialize (value));
 
-  ges_timeline_element_set_child_property (element, property_name,
-      (GValue *) value);
+  if (!ges_timeline_element_set_child_property (element, property_name,
+          (GValue *) value)) {
+    guint n_specs, i;
+    GParamSpec **specs =
+        ges_timeline_element_list_children_properties (element, &n_specs);
+    GString *errstr = g_string_new (NULL);
+
+    g_string_append_printf (errstr,
+        "\n  Could not set property `%s` on `%s`, valid properties:\n",
+        property_name, GES_TIMELINE_ELEMENT_NAME (element));
+
+    for (i = 0; i < n_specs; i++)
+      g_string_append_printf (errstr, "    - %s\n", specs[i]->name);
+    g_free (specs);
+
+    *error = g_error_new_literal (GES_ERROR, 0, errstr->str);
+    g_string_free (errstr, TRUE);
+
+    return FALSE;
+  }
   return _ges_save_timeline_if_needed (timeline, structure, error);
 }