ges: Handle g_object_newv deprecation in latest GLib
authorThibault Saunier <thibault.saunier@osg.samsung.com>
Fri, 23 Jun 2017 20:04:01 +0000 (16:04 -0400)
committerThibault Saunier <thibault.saunier@osg.samsung.com>
Fri, 23 Jun 2017 20:17:57 +0000 (16:17 -0400)
ges/ges-asset.c
ges/ges-timeline-element.c

index 60fde65..e6b142e 100644 (file)
@@ -86,6 +86,8 @@
 #include "ges.h"
 #include "ges-internal.h"
 
+#define GLIB_DISABLE_DEPRECATION_WARNINGS
+
 #include <gst/gst.h>
 
 GST_DEBUG_CATEGORY_STATIC (ges_asset_debug);
@@ -288,15 +290,38 @@ ges_asset_extract_default (GESAsset * asset, GError ** error)
   GESAssetPrivate *priv = asset->priv;
   GESExtractable *n_extractable;
 
+
   params = ges_extractable_type_get_parameters_from_id (priv->extractable_type,
       priv->id, &n_params);
 
+#if GLIB_CHECK_VERSION(2, 53, 1)
+  {
+    gint i;
+    GValue *values;
+    const gchar **names;
+
+    values = g_malloc0 (sizeof (GValue) * n_params);
+    names = g_malloc0 (sizeof (gchar **) * n_params);
+
+    for (i = 0; i < n_params; i++) {
+      values[i] = params[i].value;
+      names[i] = params[i].name;
+    }
+
+    n_extractable =
+        GES_EXTRACTABLE (g_object_new_with_properties (priv->extractable_type,
+            n_params, names, values));
+    g_free (names);
+    g_free (values);
+  }
+#else
   n_extractable = g_object_newv (priv->extractable_type, n_params, params);
+#endif
 
   while (n_params--)
     g_value_unset (&params[n_params].value);
-  if (params)
-    g_free (params);
+
+  g_free (params);
 
   return n_extractable;
 }
index 0211cd0..818f621 100644 (file)
@@ -1132,7 +1132,31 @@ ges_timeline_element_copy (GESTimelineElement * self, gboolean deep)
     }
   }
 
+#if GLIB_CHECK_VERSION(2, 53, 1)
+  {
+    gint i;
+    GValue *values;
+    const gchar **names;
+    values = g_malloc0 (sizeof (GValue) * n_specs);
+    names = g_malloc0 (sizeof (gchar **) * n_specs);
+
+    for (i = 0; i < n_params; i++) {
+      values[i] = params[i].value;
+      names[i] = params[i].name;
+    }
+
+    ret =
+        GES_TIMELINE_ELEMENT (g_object_new_with_properties (G_OBJECT_TYPE
+            (self), n_params, names, values));
+    g_free (names);
+    g_free (values);
+  }
+#else
   ret = g_object_newv (G_OBJECT_TYPE (self), n_params, params);
+#endif
+
+  while (n_params--)
+    g_value_unset (&params[n_params].value);
 
   g_free (specs);
   g_free (params);