clutter/pango: Use memory management macros
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4004>
This commit is contained in:
parent
e0291b4e8f
commit
f60e9e5e0d
3 changed files with 15 additions and 28 deletions
|
@ -152,11 +152,7 @@ _cogl_pango_display_list_add_texture (CoglPangoDisplayList *dl,
|
||||||
: !node->color_override))
|
: !node->color_override))
|
||||||
{
|
{
|
||||||
/* Get rid of the vertex buffer so that it will be recreated */
|
/* Get rid of the vertex buffer so that it will be recreated */
|
||||||
if (node->d.texture.primitive != NULL)
|
g_clear_object (&node->d.texture.primitive);
|
||||||
{
|
|
||||||
g_object_unref (node->d.texture.primitive);
|
|
||||||
node->d.texture.primitive = NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -469,16 +465,13 @@ _cogl_pango_display_list_node_free (CoglPangoDisplayListNode *node)
|
||||||
if (node->type == COGL_PANGO_DISPLAY_LIST_TEXTURE)
|
if (node->type == COGL_PANGO_DISPLAY_LIST_TEXTURE)
|
||||||
{
|
{
|
||||||
g_array_free (node->d.texture.rectangles, TRUE);
|
g_array_free (node->d.texture.rectangles, TRUE);
|
||||||
if (node->d.texture.texture != NULL)
|
g_clear_object (&node->d.texture.texture);
|
||||||
g_object_unref (node->d.texture.texture);
|
g_clear_object (&node->d.texture.primitive);
|
||||||
if (node->d.texture.primitive != NULL)
|
|
||||||
g_object_unref (node->d.texture.primitive);
|
|
||||||
}
|
}
|
||||||
else if (node->type == COGL_PANGO_DISPLAY_LIST_TRAPEZOID)
|
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_clear_object (&node->pipeline);
|
||||||
g_object_unref (node->pipeline);
|
|
||||||
|
|
||||||
g_free (node);
|
g_free (node);
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,15 +72,14 @@ struct _CoglPangoGlyphCacheKey
|
||||||
static void
|
static void
|
||||||
cogl_pango_glyph_cache_value_free (CoglPangoGlyphCacheValue *value)
|
cogl_pango_glyph_cache_value_free (CoglPangoGlyphCacheValue *value)
|
||||||
{
|
{
|
||||||
if (value->texture)
|
g_clear_object (&value->texture);
|
||||||
g_object_unref (value->texture);
|
|
||||||
g_free (value);
|
g_free (value);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
cogl_pango_glyph_cache_key_free (CoglPangoGlyphCacheKey *key)
|
cogl_pango_glyph_cache_key_free (CoglPangoGlyphCacheKey *key)
|
||||||
{
|
{
|
||||||
g_object_unref (key->font);
|
g_clear_object (&key->font);
|
||||||
g_free (key);
|
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_foreach (cache->atlases, (GFunc) g_object_unref, NULL);
|
||||||
g_slist_free (cache->atlases);
|
g_clear_pointer (&cache->atlases, g_slist_free);
|
||||||
cache->atlases = NULL;
|
|
||||||
cache->has_dirty_glyphs = FALSE;
|
cache->has_dirty_glyphs = FALSE;
|
||||||
|
|
||||||
g_hash_table_remove_all (cache->hash_table);
|
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);
|
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;
|
CoglPangoGlyphCacheValue *value = user_data;
|
||||||
float tex_width, tex_height;
|
float tex_width, tex_height;
|
||||||
|
|
||||||
if (value->texture)
|
g_clear_object (&value->texture);
|
||||||
g_object_unref (value->texture);
|
|
||||||
value->texture = g_object_ref (new_texture);
|
value->texture = g_object_ref (new_texture);
|
||||||
|
|
||||||
tex_width = cogl_texture_get_width (new_texture);
|
tex_width = cogl_texture_get_width (new_texture);
|
||||||
|
|
|
@ -63,8 +63,7 @@ _cogl_pango_pipeline_cache_value_destroy (void *data)
|
||||||
{
|
{
|
||||||
CoglPangoPipelineCacheEntry *cache_entry = data;
|
CoglPangoPipelineCacheEntry *cache_entry = data;
|
||||||
|
|
||||||
if (cache_entry->texture)
|
g_clear_object (&cache_entry->texture);
|
||||||
g_object_unref (cache_entry->texture);
|
|
||||||
|
|
||||||
/* We don't need to unref the pipeline because it only takes a weak
|
/* We don't need to unref the pipeline because it only takes a weak
|
||||||
reference */
|
reference */
|
||||||
|
@ -221,14 +220,12 @@ _cogl_pango_pipeline_cache_get (CoglPangoPipelineCache *cache,
|
||||||
void
|
void
|
||||||
_cogl_pango_pipeline_cache_free (CoglPangoPipelineCache *cache)
|
_cogl_pango_pipeline_cache_free (CoglPangoPipelineCache *cache)
|
||||||
{
|
{
|
||||||
if (cache->base_texture_rgba_pipeline)
|
g_clear_object (&cache->base_texture_rgba_pipeline);
|
||||||
g_object_unref (cache->base_texture_rgba_pipeline);
|
g_clear_object (&cache->base_texture_alpha_pipeline);
|
||||||
if (cache->base_texture_alpha_pipeline)
|
|
||||||
g_object_unref (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);
|
g_free (cache);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue