From: Peng Huang Date: Mon, 15 Feb 2010 09:43:45 +0000 (+0800) Subject: Close child process in IBusComponent.Destroy X-Git-Tag: 1.2.99.20100322~17 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=200de0a7c338149afac26fcba46949103f1f70ba;p=platform%2Fupstream%2Fibus.git Close child process in IBusComponent.Destroy --- diff --git a/src/ibuscomponent.c b/src/ibuscomponent.c index 6e268aee..ad0c356e 100644 --- a/src/ibuscomponent.c +++ b/src/ibuscomponent.c @@ -76,7 +76,6 @@ ibus_component_class_init (IBusComponentClass *klass) } - static void ibus_component_init (IBusComponent *component) { @@ -90,6 +89,8 @@ ibus_component_init (IBusComponent *component) component->textdomain = NULL; component->engines = NULL; component->observed_paths = NULL; + component->pid = 0; + component->child_source_id = 0; } static void @@ -127,6 +128,17 @@ ibus_component_destroy (IBusComponent *component) g_list_free (component->engines); component->engines = NULL; + if (component->pid != 0) { + ibus_component_stop (component); + g_spawn_close_pid (component->pid); + component->pid = 0; + } + + if (component->child_source_id != 0) { + g_source_remove (component->child_source_id); + component->child_source_id = 0; + } + IBUS_OBJECT_CLASS (ibus_component_parent_class)->destroy (IBUS_OBJECT (component)); } @@ -642,6 +654,7 @@ ibus_component_child_cb (GPid pid, g_spawn_close_pid (pid); component->pid = 0; + component->child_source_id = 0; } gboolean @@ -674,15 +687,15 @@ ibus_component_start (IBusComponent *component, gboolean verbose) flags, NULL, NULL, &(component->pid), &error); - g_strfreev (argv) - ; + g_strfreev (argv); if (!retval) { g_warning ("Can not execute component %s: %s", component->name, error->message); g_error_free (error); return FALSE; } - g_child_watch_add (component->pid, (GChildWatchFunc) ibus_component_child_cb, component); + component->child_source_id = + g_child_watch_add (component->pid, (GChildWatchFunc) ibus_component_child_cb, component); return TRUE; } diff --git a/src/ibuscomponent.h b/src/ibuscomponent.h index 0cdd3234..6c9e9e3d 100644 --- a/src/ibuscomponent.h +++ b/src/ibuscomponent.h @@ -103,6 +103,10 @@ struct _IBusComponent { GList *observed_paths; GPid pid; + guint child_source_id; + + /* padding */ + gpointer pdummy[5]; // We can add 5 pointers without breaking the ABI. }; struct _IBusComponentClass {