Avoid block in bus_factory_proxy_create_engine.
authorPeng Huang <shawn.p.huang@gmail.com>
Wed, 17 Jun 2009 11:21:10 +0000 (19:21 +0800)
committerPeng Huang <shawn.p.huang@gmail.com>
Wed, 17 Jun 2009 11:22:15 +0000 (19:22 +0800)
bus/factoryproxy.c

index cf30b95ff3d64a57b6410ba63fdabae25fd4bc9d..521d60985664382cbdded203e2ebff3a5f6e7330 100644 (file)
@@ -172,21 +172,35 @@ bus_factory_proxy_create_engine (BusFactoryProxy *factory,
     g_assert (BUS_IS_FACTORY_PROXY (factory));
     g_assert (IBUS_IS_ENGINE_DESC (desc));
 
+    IBusPendingCall *pending = NULL;
     IBusMessage *reply_message;
     IBusError *error;
     BusEngineProxy *engine;
     gchar *object_path;
+    gboolean retval;
 
     if (g_list_find (factory->component->engines, desc) == NULL) {
         return NULL;
     }
 
-    reply_message = ibus_proxy_call_with_reply_and_block ((IBusProxy *) factory,
-                                                          "CreateEngine",
-                                                          -1,
-                                                          &error,
-                                                          G_TYPE_STRING, &(desc->name),
-                                                          G_TYPE_INVALID);
+    retval = ibus_proxy_call_with_reply ((IBusProxy *) factory,
+                                         "CreateEngine",
+                                         &pending,
+                                         -1,
+                                         &error,
+                                         G_TYPE_STRING, &(desc->name),
+                                         G_TYPE_INVALID);
+
+    if (!retval) {
+        g_warning ("%s: %s", error->name, error->message);
+        ibus_error_free (error);
+        return NULL;
+    }
+
+    ibus_pending_call_wait (pending);
+    reply_message = ibus_pending_call_steal_reply (pending);
+    ibus_pending_call_unref (pending);
+
     if (reply_message == NULL) {
         g_warning ("%s: %s", error->name, error->message);
         ibus_error_free (error);