text: Consistently protect against NULL strings

When calling clutter_text_set_text_internal() or
clutter_text_set_markup_internal() we need to make sure to pass a
non-NULL string.
This commit is contained in:
Emmanuele Bassi 2011-09-07 13:08:22 +01:00
parent c3e8d30afa
commit 320bdeac03

View File

@ -1186,10 +1186,11 @@ clutter_text_set_property (GObject *gobject,
const char *str = g_value_get_string (value); const char *str = g_value_get_string (value);
clutter_text_set_contents (self, str); clutter_text_set_contents (self, str);
if (self->priv->use_markup) if (self->priv->use_markup)
clutter_text_set_markup_internal (self, str); clutter_text_set_markup_internal (self, str ? str : "");
else else
clutter_text_set_text_internal (self, str); clutter_text_set_text_internal (self, str ? str : "");
} }
break; break;
@ -4508,6 +4509,7 @@ clutter_text_set_text (ClutterText *self,
* Pango markup, and it is logically equivalent to: * Pango markup, and it is logically equivalent to:
* *
* |[ * |[
* /* the order is important */
* clutter_text_set_text (CLUTTER_TEXT (actor), markup); * clutter_text_set_text (CLUTTER_TEXT (actor), markup);
* clutter_text_set_use_markup (CLUTTER_TEXT (actor), TRUE); * clutter_text_set_use_markup (CLUTTER_TEXT (actor), TRUE);
* ]| * ]|
@ -4522,11 +4524,7 @@ clutter_text_set_markup (ClutterText *self,
clutter_text_set_use_markup_internal (self, TRUE); clutter_text_set_use_markup_internal (self, TRUE);
clutter_text_set_contents (self, markup); clutter_text_set_contents (self, markup);
clutter_text_set_markup_internal (self, markup ? markup : "");
if (markup != NULL && *markup != '\0')
clutter_text_set_markup_internal (self, markup);
else
clutter_text_set_text_internal (self, "");
} }
/** /**