[mutter] renderer: Switch open coded list clearing to g_clear_list()



commit dc35514fb499c90c6a671238c7776b9f7e94b4e3
Author: Jonas Ã…dahl <jadahl gmail com>
Date:   Sat Apr 10 00:49:51 2021 +0200

    renderer: Switch open coded list clearing to g_clear_list()
    
    The same for MetaRendererNative.
    
    Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1820>

 src/backends/meta-renderer.c               |  6 ++----
 src/backends/native/meta-renderer-native.c | 21 ++++++++-------------
 2 files changed, 10 insertions(+), 17 deletions(-)
---
diff --git a/src/backends/meta-renderer.c b/src/backends/meta-renderer.c
index 96c05a4341..2740795cb0 100644
--- a/src/backends/meta-renderer.c
+++ b/src/backends/meta-renderer.c
@@ -143,8 +143,7 @@ meta_renderer_real_rebuild_views (MetaRenderer *renderer)
     meta_backend_get_monitor_manager (backend);
   GList *logical_monitors, *l;
 
-  g_list_free_full (priv->views, (GDestroyNotify) clutter_stage_view_destroy);
-  priv->views = NULL;
+  g_clear_list (&priv->views, (GDestroyNotify) clutter_stage_view_destroy);
 
   logical_monitors =
     meta_monitor_manager_get_logical_monitors (monitor_manager);
@@ -372,8 +371,7 @@ meta_renderer_finalize (GObject *object)
   MetaRenderer *renderer = META_RENDERER (object);
   MetaRendererPrivate *priv = meta_renderer_get_instance_private (renderer);
 
-  g_list_free_full (priv->views, g_object_unref);
-  priv->views = NULL;
+  g_clear_list (&priv->views, g_object_unref);
 
   G_OBJECT_CLASS (meta_renderer_parent_class)->finalize (object);
 }
diff --git a/src/backends/native/meta-renderer-native.c b/src/backends/native/meta-renderer-native.c
index 8c7b77687c..cab9f1d60c 100644
--- a/src/backends/native/meta-renderer-native.c
+++ b/src/backends/native/meta-renderer-native.c
@@ -587,9 +587,8 @@ dummy_power_save_page_flip_cb (gpointer user_data)
   g_list_foreach (renderer_native->power_save_page_flip_onscreens,
                   (GFunc) meta_onscreen_native_dummy_power_save_page_flip,
                   NULL);
-  g_list_free_full (renderer_native->power_save_page_flip_onscreens,
-                    g_object_unref);
-  renderer_native->power_save_page_flip_onscreens = NULL;
+  g_clear_list (&renderer_native->power_save_page_flip_onscreens,
+                g_object_unref);
   renderer_native->power_save_page_flip_source_id = 0;
 
   return G_SOURCE_REMOVE;
@@ -617,9 +616,8 @@ meta_renderer_native_queue_power_save_page_flip (MetaRendererNative *renderer_na
 static void
 clear_kept_alive_onscreens (MetaRendererNative *renderer_native)
 {
-  g_list_free_full (renderer_native->kept_alive_onscreens,
-                    g_object_unref);
-  renderer_native->kept_alive_onscreens = NULL;
+  g_clear_list (&renderer_native->kept_alive_onscreens,
+                g_object_unref);
 }
 
 void
@@ -2037,13 +2035,10 @@ meta_renderer_native_finalize (GObject *object)
 
   clear_kept_alive_onscreens (renderer_native);
 
-  if (renderer_native->power_save_page_flip_onscreens)
-    {
-      g_list_free_full (renderer_native->power_save_page_flip_onscreens,
-                        g_object_unref);
-      g_clear_handle_id (&renderer_native->power_save_page_flip_source_id,
-                         g_source_remove);
-    }
+  g_clear_list (&renderer_native->power_save_page_flip_onscreens,
+                g_object_unref);
+  g_clear_handle_id (&renderer_native->power_save_page_flip_source_id,
+                     g_source_remove);
 
   g_list_free (renderer_native->pending_mode_set_views);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]