diff --git a/clutter/clutter/pango/cogl-pango-display-list.c b/clutter/clutter/pango/cogl-pango-display-list.c index b4a447728..00521d47e 100644 --- a/clutter/clutter/pango/cogl-pango-display-list.c +++ b/clutter/clutter/pango/cogl-pango-display-list.c @@ -152,11 +152,7 @@ _cogl_pango_display_list_add_texture (CoglPangoDisplayList *dl, : !node->color_override)) { /* Get rid of the vertex buffer so that it will be recreated */ - if (node->d.texture.primitive != NULL) - { - g_object_unref (node->d.texture.primitive); - node->d.texture.primitive = NULL; - } + g_clear_object (&node->d.texture.primitive); } else { @@ -469,16 +465,13 @@ _cogl_pango_display_list_node_free (CoglPangoDisplayListNode *node) if (node->type == COGL_PANGO_DISPLAY_LIST_TEXTURE) { g_array_free (node->d.texture.rectangles, TRUE); - if (node->d.texture.texture != NULL) - g_object_unref (node->d.texture.texture); - if (node->d.texture.primitive != NULL) - g_object_unref (node->d.texture.primitive); + g_clear_object (&node->d.texture.texture); + g_clear_object (&node->d.texture.primitive); } else if (node->type == COGL_PANGO_DISPLAY_LIST_TRAPEZOID) - g_object_unref (node->d.trapezoid.primitive); + g_clear_object (&node->d.trapezoid.primitive); - if (node->pipeline) - g_object_unref (node->pipeline); + g_clear_object (&node->pipeline); g_free (node); } diff --git a/clutter/clutter/pango/cogl-pango-glyph-cache.c b/clutter/clutter/pango/cogl-pango-glyph-cache.c index 478c6ee40..998d40842 100644 --- a/clutter/clutter/pango/cogl-pango-glyph-cache.c +++ b/clutter/clutter/pango/cogl-pango-glyph-cache.c @@ -72,15 +72,14 @@ struct _CoglPangoGlyphCacheKey static void cogl_pango_glyph_cache_value_free (CoglPangoGlyphCacheValue *value) { - if (value->texture) - g_object_unref (value->texture); + g_clear_object (&value->texture); g_free (value); } static void cogl_pango_glyph_cache_key_free (CoglPangoGlyphCacheKey *key) { - g_object_unref (key->font); + g_clear_object (&key->font); g_free (key); } @@ -158,12 +157,11 @@ cogl_pango_glyph_cache_free (CoglPangoGlyphCache *cache) } g_slist_foreach (cache->atlases, (GFunc) g_object_unref, NULL); - g_slist_free (cache->atlases); - cache->atlases = NULL; + g_clear_pointer (&cache->atlases, g_slist_free); cache->has_dirty_glyphs = FALSE; g_hash_table_remove_all (cache->hash_table); - g_hash_table_unref (cache->hash_table); + g_clear_pointer (&cache->hash_table, g_hash_table_unref); g_hook_list_clear (&cache->reorganize_callbacks); @@ -178,8 +176,7 @@ cogl_pango_glyph_cache_update_position_cb (void *user_data, CoglPangoGlyphCacheValue *value = user_data; float tex_width, tex_height; - if (value->texture) - g_object_unref (value->texture); + g_clear_object (&value->texture); value->texture = g_object_ref (new_texture); tex_width = cogl_texture_get_width (new_texture); diff --git a/clutter/clutter/pango/cogl-pango-pipeline-cache.c b/clutter/clutter/pango/cogl-pango-pipeline-cache.c index bd6d44b00..4beeb596b 100644 --- a/clutter/clutter/pango/cogl-pango-pipeline-cache.c +++ b/clutter/clutter/pango/cogl-pango-pipeline-cache.c @@ -63,8 +63,7 @@ _cogl_pango_pipeline_cache_value_destroy (void *data) { CoglPangoPipelineCacheEntry *cache_entry = data; - if (cache_entry->texture) - g_object_unref (cache_entry->texture); + g_clear_object (&cache_entry->texture); /* We don't need to unref the pipeline because it only takes a weak reference */ @@ -221,14 +220,12 @@ _cogl_pango_pipeline_cache_get (CoglPangoPipelineCache *cache, void _cogl_pango_pipeline_cache_free (CoglPangoPipelineCache *cache) { - if (cache->base_texture_rgba_pipeline) - g_object_unref (cache->base_texture_rgba_pipeline); - if (cache->base_texture_alpha_pipeline) - g_object_unref (cache->base_texture_alpha_pipeline); + g_clear_object (&cache->base_texture_rgba_pipeline); + g_clear_object (&cache->base_texture_alpha_pipeline); - g_hash_table_destroy (cache->hash_table); + g_clear_pointer (&cache->hash_table, g_hash_table_destroy); - g_object_unref (cache->ctx); + g_clear_object (&cache->ctx); g_free (cache); }