Lazily create the PangoContext on Text::init

If we create the PangoContext for ClutterText inside the class
initialization we might not have a Clutter main context yet.

Ideally, we should store the Pango context inside the main context
and create it on clutter_init(), but for now we can lazily create
the PangoContext when we initialize a ClutterText instance for the
first time.
This commit is contained in:
Emmanuele Bassi 2008-12-11 14:57:46 +00:00
parent 5a1837bc9e
commit 0ac1590378

View File

@ -1417,8 +1417,6 @@ clutter_text_class_init (ClutterTextClass *klass)
ClutterBindingPool *binding_pool; ClutterBindingPool *binding_pool;
GParamSpec *pspec; GParamSpec *pspec;
_context = _clutter_context_create_pango_context (CLUTTER_CONTEXT ());
g_type_class_add_private (klass, sizeof (ClutterTextPrivate)); g_type_class_add_private (klass, sizeof (ClutterTextPrivate));
gobject_class->set_property = clutter_text_set_property; gobject_class->set_property = clutter_text_set_property;
@ -1829,6 +1827,9 @@ clutter_text_init (ClutterText *self)
ClutterTextPrivate *priv; ClutterTextPrivate *priv;
int i; int i;
if (G_UNLIKELY (_context == NULL))
_context = _clutter_context_create_pango_context (CLUTTER_CONTEXT ());
self->priv = priv = CLUTTER_TEXT_GET_PRIVATE (self); self->priv = priv = CLUTTER_TEXT_GET_PRIVATE (self);
priv->alignment = PANGO_ALIGN_LEFT; priv->alignment = PANGO_ALIGN_LEFT;