[mutter/gnome-3-34] clutter/offscreen-effect: Use g_clear_pointer for cleanup
- From: Robert Mader <rmader src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/gnome-3-34] clutter/offscreen-effect: Use g_clear_pointer for cleanup
- Date: Sun, 2 Feb 2020 16:55:24 +0000 (UTC)
commit d35d7fb6189de9a40a1fdd8f8c03da4aba3983a3
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Tue Jan 7 11:57:02 2020 -0300
clutter/offscreen-effect: Use g_clear_pointer for cleanup
It does the exact same checks, and saves us a few lines of code.
https://gitlab.gnome.org/GNOME/mutter/merge_requests/992
(cherry picked from commit 3958e75ed2a9afb5d32c59b017691e3ed2289ee2)
clutter/clutter/clutter-offscreen-effect.c | 30 ++++++------------------------
1 file changed, 6 insertions(+), 24 deletions(-)
---
diff --git a/clutter/clutter/clutter-offscreen-effect.c b/clutter/clutter/clutter-offscreen-effect.c
index cb554f44c..02d0f4c06 100644
--- a/clutter/clutter/clutter-offscreen-effect.c
+++ b/clutter/clutter/clutter-offscreen-effect.c
@@ -117,11 +117,7 @@ clutter_offscreen_effect_set_actor (ClutterActorMeta *meta,
meta_class->set_actor (meta, actor);
/* clear out the previous state */
- if (priv->offscreen != NULL)
- {
- cogl_handle_unref (priv->offscreen);
- priv->offscreen = NULL;
- }
+ g_clear_pointer (&priv->offscreen, cogl_object_unref);
/* we keep a back pointer here, to avoid going through the ActorMeta */
priv->actor = clutter_actor_meta_get_actor (meta);
@@ -197,17 +193,8 @@ update_fbo (ClutterEffect *effect,
ensure_pipeline_filter_for_scale (self, resource_scale);
}
- if (priv->texture != NULL)
- {
- cogl_handle_unref (priv->texture);
- priv->texture = NULL;
- }
-
- if (priv->offscreen != NULL)
- {
- cogl_handle_unref (priv->offscreen);
- priv->offscreen = NULL;
- }
+ g_clear_pointer (&priv->texture, cogl_object_unref);
+ g_clear_pointer (&priv->offscreen, cogl_object_unref);
priv->texture =
clutter_offscreen_effect_create_texture (self, target_width, target_height);
@@ -486,14 +473,9 @@ clutter_offscreen_effect_finalize (GObject *gobject)
ClutterOffscreenEffect *self = CLUTTER_OFFSCREEN_EFFECT (gobject);
ClutterOffscreenEffectPrivate *priv = self->priv;
- if (priv->offscreen)
- cogl_handle_unref (priv->offscreen);
-
- if (priv->target)
- cogl_handle_unref (priv->target);
-
- if (priv->texture)
- cogl_handle_unref (priv->texture);
+ g_clear_pointer (&priv->offscreen, cogl_object_unref);
+ g_clear_pointer (&priv->texture, cogl_object_unref);
+ g_clear_pointer (&priv->target, cogl_object_unref);
G_OBJECT_CLASS (clutter_offscreen_effect_parent_class)->finalize (gobject);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]