Don't use deprecated g_object_newv()
authorTim-Philipp Müller <tim@centricular.com>
Tue, 4 Apr 2017 16:53:39 +0000 (17:53 +0100)
committerTim-Philipp Müller <tim@centricular.com>
Sat, 8 Apr 2017 08:49:59 +0000 (09:49 +0100)
Use g_object_new() instead which nowadays has a shortcut for the
no-properties check. It still does an extra GType check in the
function guard, but there's a pending patch to remove that
and it's hardly going to be a performance issue in practice,
even less so on a system that's compiled without run-time checks.

Alternative would be to move to the new g_object_new_properties()
with a fallback define for older glib versions, but it makes the
code look more unwieldy and doesn't seem worth it.

Fixes deprecation warnings when building against newer GLib versions.

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

22 files changed:
gst/gstbufferpool.c
gst/gstbus.c
gst/gstdeviceproviderfactory.c
gst/gstdynamictypefactory.c
gst/gstelementfactory.c
gst/gstplugin.c
gst/gstpluginloader.c
gst/gstregistry.c
gst/gstregistrychunks.c
gst/gsttask.c
gst/gsttaskpool.c
gst/gsttracer.c
gst/gsttracerrecord.c
gst/gsttypefind.c
libs/gst/base/gstadapter.c
libs/gst/base/gstdataqueue.c
libs/gst/base/gstindex.c
libs/gst/controller/gstinterpolationcontrolsource.c
libs/gst/controller/gstlfocontrolsource.c
libs/gst/controller/gsttriggercontrolsource.c
tests/check/gst/gstcontroller.c
tests/check/gst/gstelementfactory.c

index f984a26e4c5dbf108da116d9e082548a9cfad773..9529208aa065644f75b500c257102b1ad9d4325f 100644 (file)
@@ -219,7 +219,7 @@ gst_buffer_pool_new (void)
 {
   GstBufferPool *result;
 
-  result = g_object_newv (GST_TYPE_BUFFER_POOL, 0, NULL);
+  result = g_object_new (GST_TYPE_BUFFER_POOL, NULL);
   GST_DEBUG_OBJECT (result, "created new buffer pool");
 
   return result;
index 7bf71b649c5781e983e52f3991c3b8d52b68d42d..6a7820cbb14e55caa4a03f4d93ea069bf95f3451 100644 (file)
@@ -285,7 +285,7 @@ gst_bus_new (void)
 {
   GstBus *result;
 
-  result = g_object_newv (gst_bus_get_type (), 0, NULL);
+  result = g_object_new (gst_bus_get_type (), NULL);
   GST_DEBUG_OBJECT (result, "created new bus");
 
   return result;
index 85dc53d141c36eb26d0016d741bdd2f0bd7bd0f2..3fbaa3b2f14e9be31148682dd5f9d366796cf4c0 100644 (file)
@@ -197,9 +197,7 @@ gst_device_provider_register (GstPlugin * plugin, const gchar * name,
     return TRUE;
   }
 
-  factory =
-      GST_DEVICE_PROVIDER_FACTORY_CAST (g_object_newv
-      (GST_TYPE_DEVICE_PROVIDER_FACTORY, 0, NULL));
+  factory = g_object_new (GST_TYPE_DEVICE_PROVIDER_FACTORY, NULL);
   gst_plugin_feature_set_name (GST_PLUGIN_FEATURE_CAST (factory), name);
   GST_LOG_OBJECT (factory, "Created new device providerfactory for type %s",
       g_type_name (type));
@@ -284,8 +282,7 @@ gst_device_provider_factory_get (GstDeviceProviderFactory * factory)
   /* create an instance of the device provider, cast so we don't assert on NULL
    * also set name as early as we can
    */
-  device_provider = GST_DEVICE_PROVIDER_CAST (g_object_newv (factory->type, 0,
-          NULL));
+  device_provider = g_object_new (factory->type, NULL);
   if (G_UNLIKELY (device_provider == NULL))
     goto no_device_provider;
 
index 5f52ac23f0c5174238e252d8172b64da9eca677d..cb388a5dfdae0ec7bd3cf88dffe490756d250524 100644 (file)
@@ -123,9 +123,7 @@ gst_dynamic_type_factory_create (GstRegistry * registry,
 {
   GstDynamicTypeFactory *factory;
 
-  factory =
-      GST_DYNAMIC_TYPE_FACTORY_CAST (g_object_newv
-      (GST_TYPE_DYNAMIC_TYPE_FACTORY, 0, NULL));
+  factory = g_object_new (GST_TYPE_DYNAMIC_TYPE_FACTORY, NULL);
   gst_plugin_feature_set_name (GST_PLUGIN_FEATURE_CAST (factory), name);
   GST_LOG_OBJECT (factory, "Created new dynamictypefactory for type %s", name);
 
index 20704a00d6de9b97bacee55c745d261bc4720613..da64380ee90ced73e9858fd17953f9a56eb63902 100644 (file)
@@ -230,9 +230,7 @@ gst_element_register (GstPlugin * plugin, const gchar * name, guint rank,
     return TRUE;
   }
 
-  factory =
-      GST_ELEMENT_FACTORY_CAST (g_object_newv (GST_TYPE_ELEMENT_FACTORY, 0,
-          NULL));
+  factory = g_object_new (GST_TYPE_ELEMENT_FACTORY, NULL);
   gst_plugin_feature_set_name (GST_PLUGIN_FEATURE_CAST (factory), name);
   GST_LOG_OBJECT (factory, "Created new elementfactory for type %s",
       g_type_name (type));
@@ -369,10 +367,9 @@ gst_element_factory_create (GstElementFactory * factory, const gchar * name)
    * also set name as early as we can
    */
   if (name)
-    element =
-        GST_ELEMENT_CAST (g_object_new (factory->type, "name", name, NULL));
+    element = g_object_new (factory->type, "name", name, NULL);
   else
-    element = GST_ELEMENT_CAST (g_object_newv (factory->type, 0, NULL));
+    element = g_object_new (factory->type, NULL);
   if (G_UNLIKELY (element == NULL))
     goto no_element;
 
index 6285983de90af815082de43e15c7bf7c1147cf0e..506478dcd20e1f796423d35eef89ca48aafc6edf 100644 (file)
@@ -220,7 +220,7 @@ gst_plugin_register_static (gint major_version, gint minor_version,
   g_return_val_if_fail (_gst_plugin_inited != FALSE, FALSE);
 
   GST_LOG ("attempting to load static plugin \"%s\" now...", name);
-  plugin = g_object_newv (GST_TYPE_PLUGIN, 0, NULL);
+  plugin = g_object_new (GST_TYPE_PLUGIN, NULL);
   if (gst_plugin_register_func (plugin, &desc, NULL) != NULL) {
     GST_INFO ("registered static plugin \"%s\"", name);
     res = gst_registry_add_plugin (gst_registry_get (), plugin);
@@ -287,7 +287,7 @@ gst_plugin_register_static_full (gint major_version, gint minor_version,
   g_return_val_if_fail (_gst_plugin_inited != FALSE, FALSE);
 
   GST_LOG ("attempting to load static plugin \"%s\" now...", name);
-  plugin = g_object_newv (GST_TYPE_PLUGIN, 0, NULL);
+  plugin = g_object_new (GST_TYPE_PLUGIN, NULL);
   if (gst_plugin_register_func (plugin, &desc, user_data) != NULL) {
     GST_INFO ("registered static plugin \"%s\"", name);
     res = gst_registry_add_plugin (gst_registry_get (), plugin);
@@ -781,7 +781,7 @@ _priv_gst_plugin_load_file_for_registry (const gchar * filename,
   }
 
   if (new_plugin) {
-    plugin = g_object_newv (GST_TYPE_PLUGIN, 0, NULL);
+    plugin = g_object_new (GST_TYPE_PLUGIN, NULL);
     plugin->file_mtime = file_status.st_mtime;
     plugin->file_size = file_status.st_size;
     plugin->filename = g_strdup (filename);
index dbd341dd1c6710e30a99d984f5286b96ec7393ed..430829d3f479349d3e30634bb0f6750fe1e1435c 100644 (file)
@@ -339,7 +339,7 @@ static void
 plugin_loader_create_blacklist_plugin (GstPluginLoader * l,
     PendingPluginEntry * entry)
 {
-  GstPlugin *plugin = g_object_newv (GST_TYPE_PLUGIN, 0, NULL);
+  GstPlugin *plugin = g_object_new (GST_TYPE_PLUGIN, NULL);
 
   plugin->filename = g_strdup (entry->filename);
   plugin->file_mtime = entry->file_mtime;
index 7ea77841ff92746f90f782e93d0c646cc2190293..dbd373a108021220d3d03d2a6a499e78d3c1e5a4 100644 (file)
@@ -327,7 +327,7 @@ gst_registry_get (void)
 
   g_mutex_lock (&_gst_registry_mutex);
   if (G_UNLIKELY (!_gst_registry_default)) {
-    _gst_registry_default = g_object_newv (GST_TYPE_REGISTRY, 0, NULL);
+    _gst_registry_default = g_object_new (GST_TYPE_REGISTRY, NULL);
     gst_object_ref_sink (GST_OBJECT_CAST (_gst_registry_default));
   }
   registry = _gst_registry_default;
index 193bb60c591d36c72b21fb09ec234b03c22a284d..899b83d17f5a9d5dfa9bd7fc9152a64b7761c3af 100644 (file)
@@ -576,7 +576,7 @@ gst_registry_chunks_load_feature (GstRegistry * registry, gchar ** in,
         plugin_name);
     return FALSE;
   }
-  if (G_UNLIKELY ((feature = g_object_newv (type, 0, NULL)) == NULL)) {
+  if (G_UNLIKELY ((feature = g_object_new (type, NULL)) == NULL)) {
     GST_ERROR ("Can't create feature from type");
     return FALSE;
   }
@@ -827,7 +827,7 @@ _priv_gst_registry_chunks_load_plugin (GstRegistry * registry, gchar ** in,
       *in);
   unpack_element (*in, pe, GstRegistryChunkPluginElement, end, fail);
 
-  plugin = g_object_newv (GST_TYPE_PLUGIN, 0, NULL);
+  plugin = g_object_new (GST_TYPE_PLUGIN, NULL);
 
   /* TODO: also set GST_PLUGIN_FLAG_CONST */
   GST_OBJECT_FLAG_SET (plugin, GST_PLUGIN_FLAG_CACHED);
index d5ce87c64cfc943dbbe5c6a3cfa40e3f9b641282..d231bd12b9b20392e4efb94e994a320c85ad52ba 100644 (file)
@@ -423,7 +423,7 @@ gst_task_new (GstTaskFunction func, gpointer user_data, GDestroyNotify notify)
 
   g_return_val_if_fail (func != NULL, NULL);
 
-  task = g_object_newv (GST_TYPE_TASK, 0, NULL);
+  task = g_object_new (GST_TYPE_TASK, NULL);
   task->func = func;
   task->user_data = user_data;
   task->notify = notify;
index 18f0a610cc4b6b75d29b295403d3151b06d59c8e..cd0320fb9da787402cdbbfcf787251527cc66b96 100644 (file)
@@ -166,7 +166,7 @@ gst_task_pool_new (void)
 {
   GstTaskPool *pool;
 
-  pool = g_object_newv (GST_TYPE_TASK_POOL, 0, NULL);
+  pool = g_object_new (GST_TYPE_TASK_POOL, NULL);
 
   return pool;
 }
index a75fb994ce97f60ca34c61e052f1caed09e3fc8e..25cc94f807315da67866604f7a4d4a23cb7fb181 100644 (file)
@@ -169,7 +169,7 @@ gst_tracer_register (GstPlugin * plugin, const gchar * name, GType type)
     return TRUE;
   }
 
-  factory = g_object_newv (GST_TYPE_TRACER_FACTORY, 0, NULL);
+  factory = g_object_new (GST_TYPE_TRACER_FACTORY, NULL);
   GST_DEBUG_OBJECT (factory, "new tracer factory for %s", name);
 
   gst_plugin_feature_set_name (GST_PLUGIN_FEATURE_CAST (factory), name);
index 00102bdd11e5347d8344632cc52d559fea969677..c6651d212a39c33c7f29a3fe6c0f9ee8229ca855 100644 (file)
@@ -218,7 +218,7 @@ gst_tracer_record_new (const gchar * name, const gchar * firstfield, ...)
   }
   va_end (varargs);
 
-  self = g_object_newv (GST_TYPE_TRACER_RECORD, 0, NULL);
+  self = g_object_new (GST_TYPE_TRACER_RECORD, NULL);
   self->spec = structure;
   gst_tracer_record_build_format (self);
 
index 93ea3cd100e01aecb85f2adba8f59b290c89eaa0..5c2b0d15cf934746d33cf8f27d0f8f7962ed7c85 100644 (file)
@@ -71,7 +71,7 @@ gst_type_find_register (GstPlugin * plugin, const gchar * name, guint rank,
 
   GST_INFO ("registering typefind function for %s", name);
 
-  factory = g_object_newv (GST_TYPE_TYPE_FIND_FACTORY, 0, NULL);
+  factory = g_object_new (GST_TYPE_TYPE_FIND_FACTORY, NULL);
   GST_DEBUG_OBJECT (factory, "using new typefind factory for %s", name);
 
   gst_plugin_feature_set_name (GST_PLUGIN_FEATURE_CAST (factory), name);
index bd62abe7a35e461f557bcf0caa49f46fa930765f..6c56c41f9a3792fe4f0ef8a5a454876bfadf1139 100644 (file)
@@ -240,7 +240,7 @@ gst_adapter_finalize (GObject * object)
 GstAdapter *
 gst_adapter_new (void)
 {
-  return g_object_newv (GST_TYPE_ADAPTER, 0, NULL);
+  return g_object_new (GST_TYPE_ADAPTER, NULL);
 }
 
 /**
index 5c1c574e1c82006f710dd88d358cc227f34a546b..ab09cb6fd064b6f951f4565cc2b22e0134e797d3 100644 (file)
@@ -236,7 +236,7 @@ gst_data_queue_new (GstDataQueueCheckFullFunction checkfull,
 
   g_return_val_if_fail (checkfull != NULL, NULL);
 
-  ret = g_object_newv (GST_TYPE_DATA_QUEUE, 0, NULL);
+  ret = g_object_new (GST_TYPE_DATA_QUEUE, NULL);
   ret->priv->checkfull = checkfull;
   ret->priv->checkdata = checkdata;
   ret->priv->fullcallback = fullcallback;
index 1df5bd2c6bf9f1239e045c6c723309eea467d84a..80fbfe9ec9ff23dabca83970d6570d3d72d04227 100644 (file)
@@ -305,7 +305,7 @@ gst_index_new (void)
 {
   GstIndex *index;
 
-  index = g_object_newv (gst_index_get_type (), 0, NULL);
+  index = g_object_new (gst_index_get_type (), NULL);
 
   return index;
 }
index 21f5feab5a3a1309060acc68ec242cf2e6fa4537..ff8d8f70073a999608c527b02b0c997d59ed9071 100644 (file)
@@ -666,7 +666,7 @@ struct _GstInterpolationControlSourcePrivate
 GstControlSource *
 gst_interpolation_control_source_new (void)
 {
-  return g_object_newv (GST_TYPE_INTERPOLATION_CONTROL_SOURCE, 0, NULL);
+  return g_object_new (GST_TYPE_INTERPOLATION_CONTROL_SOURCE, NULL);
 }
 
 static gboolean
index 403adf54144088f5e3b8434222a2ac8ed1f051ca..e0adaafd9a3afed36b37b58671317ed498831fda 100644 (file)
@@ -424,7 +424,7 @@ gst_lfo_control_source_reset (GstLFOControlSource * self)
 GstControlSource *
 gst_lfo_control_source_new (void)
 {
-  return g_object_newv (GST_TYPE_LFO_CONTROL_SOURCE, 0, NULL);
+  return g_object_new (GST_TYPE_LFO_CONTROL_SOURCE, NULL);
 }
 
 static gboolean
index 8fd0c830256215c2fff73be4a8fd5b608e9fd241..438ccb19fc9529f344197dcc5a4ad5487b5f2fe5 100644 (file)
@@ -188,7 +188,7 @@ G_DEFINE_TYPE_WITH_CODE (GstTriggerControlSource, gst_trigger_control_source,
 GstControlSource *
 gst_trigger_control_source_new (void)
 {
-  return g_object_newv (GST_TYPE_TRIGGER_CONTROL_SOURCE, 0, NULL);
+  return g_object_new (GST_TYPE_TRIGGER_CONTROL_SOURCE, NULL);
 }
 
 static void
index 531e7271522a089e30b8208a4788e21624a4591b..ed91ffc3e6b660119be40d5bf1d60f44c1f1151e 100644 (file)
@@ -231,7 +231,7 @@ static GType gst_test_control_source_get_type (void);
 static GstTestControlSource *
 gst_test_control_source_new (void)
 {
-  return g_object_newv (GST_TYPE_TEST_CONTROL_SOURCE, 0, NULL);
+  return g_object_new (GST_TYPE_TEST_CONTROL_SOURCE, NULL);
 }
 
 static gboolean
index 47c125cde7f4a14e9f0c1e549c40c8e2abcf13b5..294ebf13f910705ea6c1f11baf2d171e76378fd1 100644 (file)
@@ -50,7 +50,7 @@ setup_factory (void)
   GstPluginFeature *feature;
   GstElementFactory *factory;
 
-  feature = g_object_newv (GST_TYPE_ELEMENT_FACTORY, 0, NULL);
+  feature = g_object_new (GST_TYPE_ELEMENT_FACTORY, NULL);
   gst_plugin_feature_set_name (feature, "test");
 
   factory = GST_ELEMENT_FACTORY_CAST (feature);