clutter-text: prevent text buffer creation if not needed
When allocating or asking for preferred width/height on a ClutterText, it can notify a change on buffer/text/max-length if no text has been set. https://bugzilla.gnome.org/show_bug.cgi?id=703882
This commit is contained in:
parent
6227f7a0f5
commit
eed9496056
@ -344,6 +344,18 @@ clutter_text_clear_selection (ClutterText *self)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
clutter_text_is_empty (ClutterText *self)
|
||||||
|
{
|
||||||
|
if (self->priv->buffer == NULL)
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
if (clutter_text_buffer_get_length (self->priv->buffer) == 0)
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
static gchar *
|
static gchar *
|
||||||
clutter_text_get_display_text (ClutterText *self)
|
clutter_text_get_display_text (ClutterText *self)
|
||||||
{
|
{
|
||||||
@ -351,6 +363,13 @@ clutter_text_get_display_text (ClutterText *self)
|
|||||||
ClutterTextBuffer *buffer;
|
ClutterTextBuffer *buffer;
|
||||||
const gchar *text;
|
const gchar *text;
|
||||||
|
|
||||||
|
/* short-circuit the case where the buffer is unset or it's empty,
|
||||||
|
* to avoid creating a pointless TextBuffer and emitting
|
||||||
|
* notifications with it
|
||||||
|
*/
|
||||||
|
if (clutter_text_is_empty (self))
|
||||||
|
return g_strdup ("");
|
||||||
|
|
||||||
buffer = get_buffer (self);
|
buffer = get_buffer (self);
|
||||||
text = clutter_text_buffer_get_text (buffer);
|
text = clutter_text_buffer_get_text (buffer);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user