[gegl] Fix initiazation order
- From: Daniel Sabo <daniels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl] Fix initiazation order
- Date: Sun, 31 Mar 2013 23:25:29 +0000 (UTC)
commit 6c11f31bec6c78c30b856fe59422cfffb0c9a080
Author: Daniel Sabo <DanielSabo gmail com>
Date: Sat Mar 30 23:26:29 2013 -0700
Fix initiazation order
GObject introspection would crash when opencl was available because
it constructed a GeglConfig object without calling gegl_init. However
this was only part of the problem because calling gegl_config before
init will cause gegl_init to silently bail out without actually
setting up Gegl.
In order to both avoid the introspection crash and allow the user to
modify settings before calling gegl_init I've switched to the
slightly ugly notify::use-opencl based trigger for gegl_cl_init.
I also changed gegl_init to track it's own state instead of checking
for the existence of GeglConfig.
gegl/gegl-config.c | 4 ----
gegl/gegl-init.c | 42 +++++++++++++++++++++++++++++++++++++-----
2 files changed, 37 insertions(+), 9 deletions(-)
---
diff --git a/gegl/gegl-config.c b/gegl/gegl-config.c
index e985f78..9d67bd9 100644
--- a/gegl/gegl-config.c
+++ b/gegl/gegl-config.c
@@ -176,10 +176,6 @@ gegl_config_set_property (GObject *gobject,
return;
case PROP_USE_OPENCL:
config->use_opencl = g_value_get_boolean (value);
-
- if (config->use_opencl)
- config->use_opencl = gegl_cl_init (NULL);
-
break;
case PROP_QUEUE_LIMIT:
config->queue_limit = g_value_get_int (value);
diff --git a/gegl/gegl-init.c b/gegl/gegl-init.c
index 86a377b..1aab900 100644
--- a/gegl/gegl-init.c
+++ b/gegl/gegl-init.c
@@ -164,6 +164,32 @@ static glong global_time = 0;
static const gchar *makefile (void);
static void
+gegl_config_use_opencl_notify (GObject *gobject,
+ GParamSpec *pspec,
+ gpointer user_data)
+{
+ GeglConfig *cfg = GEGL_CONFIG (gobject);
+ gboolean use_opencl = cfg->use_opencl;
+
+ if (use_opencl)
+ {
+ g_signal_handlers_block_by_func (gobject,
+ gegl_config_use_opencl_notify,
+ NULL);
+
+ use_opencl = gegl_cl_init (NULL);
+
+ g_object_set (gobject,
+ "use-opencl", use_opencl,
+ NULL);
+
+ g_signal_handlers_unblock_by_func (gobject,
+ gegl_config_use_opencl_notify,
+ NULL);
+ }
+}
+
+static void
gegl_init_i18n (void)
{
setlocale (LC_ALL, "");
@@ -177,9 +203,13 @@ gegl_init (gint *argc,
{
GOptionContext *context;
GError *error = NULL;
- if (config)
+ static gboolean initialized = FALSE;
+
+ if (initialized)
return;
+ initialized = TRUE;
+
gegl_init_i18n ();
context = g_option_context_new (NULL);
@@ -469,10 +499,6 @@ gegl_post_parse_hook (GOptionContext *context,
{
glong time;
- if (config)
- return TRUE;
-
-
g_assert (global_time == 0);
global_time = gegl_ticks ();
g_type_init ();
@@ -599,6 +625,12 @@ gegl_post_parse_hook (GOptionContext *context,
swap_clean ();
+ g_signal_connect (G_OBJECT (config),
+ "notify::use-opencl",
+ G_CALLBACK (gegl_config_use_opencl_notify),
+ NULL);
+ g_object_set (config, "use-opencl", config->use_opencl, NULL);
+
return TRUE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]