mirror of
https://github.com/brl/mutter.git
synced 2024-12-23 19:42:05 +00:00
Allow checking initialization without side-effects
The _clutter_context_get_default() function will automatically create the main Clutter context; if we just want to check whether Clutter has been initialized this will complicate matters, by requiring a call to g_type_init() inside the client code. Instead, we should simply provide an internal API that checks whether the main Clutter context exists and if it has been initialized, without any side effect.
This commit is contained in:
parent
184df2a5fa
commit
b5f4befeaa
@ -1052,10 +1052,19 @@ clutter_get_debug_enabled (void)
|
||||
#endif
|
||||
}
|
||||
|
||||
gboolean
|
||||
_clutter_context_is_initialized (void)
|
||||
{
|
||||
if (ClutterCntx == NULL)
|
||||
return FALSE;
|
||||
|
||||
return ClutterCntx->is_initialized;
|
||||
}
|
||||
|
||||
ClutterMainContext *
|
||||
_clutter_context_get_default (void)
|
||||
{
|
||||
if (G_UNLIKELY(!ClutterCntx))
|
||||
if (G_UNLIKELY (ClutterCntx == NULL))
|
||||
{
|
||||
ClutterMainContext *ctx;
|
||||
|
||||
@ -1067,7 +1076,7 @@ _clutter_context_get_default (void)
|
||||
ctx->motion_events_per_actor = TRUE;
|
||||
|
||||
#ifdef CLUTTER_ENABLE_DEBUG
|
||||
ctx->timer = g_timer_new ();
|
||||
ctx->timer = g_timer_new ();
|
||||
g_timer_start (ctx->timer);
|
||||
#endif
|
||||
}
|
||||
|
@ -138,6 +138,7 @@ struct _ClutterMainContext
|
||||
|
||||
#define CLUTTER_CONTEXT() (_clutter_context_get_default ())
|
||||
ClutterMainContext *_clutter_context_get_default (void);
|
||||
gboolean _clutter_context_is_initialized (void);
|
||||
PangoContext *_clutter_context_create_pango_context (ClutterMainContext *self);
|
||||
PangoContext *_clutter_context_get_pango_context (ClutterMainContext *self);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user