summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmmanuele Bassi <ebassi@gnome.org>2013-03-04 13:02:44 +0000
committerEmmanuele Bassi <ebassi@gnome.org>2013-03-04 23:13:14 +0000
commitba1ff388b1d83a7618714a5c3fc3f266c7c30ca4 (patch)
tree92b381d64d15a196a264fa0ed2b3cf3c90995bd8
parent61f705f7248ff372df355564ec262696900a1c7e (diff)
downloadclutter-ba1ff388b1d83a7618714a5c3fc3f266c7c30ca4.tar.gz
text: Clean up the set_font_description_internal() semantics
The current semantics are ridiculous, and clearly a case of (mistaken) premature optimization. All setters should copy, not transfer ownership. https://bugzilla.gnome.org/show_bug.cgi?id=695119
-rw-r--r--clutter/clutter-text.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/clutter/clutter-text.c b/clutter/clutter-text.c
index 3cefa83fb..b460c1862 100644
--- a/clutter/clutter-text.c
+++ b/clutter/clutter-text.c
@@ -557,8 +557,7 @@ clutter_text_dirty_cache (ClutterText *text)
* @desc: a #PangoFontDescription
*
* Sets @desc as the font description to be used by the #ClutterText
- * actor. The font description ownership is transferred to @self so
- * the #PangoFontDescription must not be freed after this function
+ * actor. The #PangoFontDescription is copied.
*
* This function will also set the :font-name field as a side-effect
*
@@ -577,7 +576,7 @@ clutter_text_set_font_description_internal (ClutterText *self,
if (priv->font_desc != NULL)
pango_font_description_free (priv->font_desc);
- priv->font_desc = desc;
+ priv->font_desc = pango_font_description_copy (desc);
/* update the font name string we use */
g_free (priv->font_name);
@@ -619,6 +618,7 @@ clutter_text_settings_changed_cb (ClutterText *text)
font_desc = pango_font_description_from_string (font_name);
clutter_text_set_font_description_internal (text, font_desc);
+ pango_font_description_free (font_desc);
g_free (font_name);
}
@@ -4918,12 +4918,9 @@ void
clutter_text_set_font_description (ClutterText *self,
PangoFontDescription *font_desc)
{
- PangoFontDescription *copy;
-
g_return_if_fail (CLUTTER_IS_TEXT (self));
- copy = pango_font_description_copy (font_desc);
- clutter_text_set_font_description_internal (self, copy);
+ clutter_text_set_font_description_internal (self, font_desc);
}
/**
@@ -5021,7 +5018,7 @@ clutter_text_set_font_name (ClutterText *self,
goto out;
desc = pango_font_description_from_string (font_name);
- if (!desc)
+ if (desc == NULL)
{
g_warning ("Attempting to create a PangoFontDescription for "
"font name '%s', but failed.",
@@ -5035,6 +5032,8 @@ clutter_text_set_font_name (ClutterText *self,
g_object_notify_by_pspec (G_OBJECT (self), obj_props[PROP_FONT_NAME]);
+ pango_font_description_free (desc);
+
out:
if (is_default_font)
g_free ((gchar *) font_name);