atspi: recover init failure 05/257405/4
authorShinwoo Kim <cinoo.kim@samsung.com>
Fri, 23 Apr 2021 08:42:16 +0000 (17:42 +0900)
committerLukasz Oleksak <l.oleksak@samsung.com>
Wed, 12 May 2021 08:33:34 +0000 (08:33 +0000)
There is an application which is trying to init atspi bridge
before DBus is ready. In this case, it is not able to create
atspi bridge instance.

Change-Id: Ie5a0b37ddb814ded90d4e205ef0ccedc9c85c932

src/lib/elementary/elm_atspi_bridge.c

index a81e6da..3ddae2b 100644 (file)
@@ -164,6 +164,9 @@ struct collection_match_rule {
 };
 
 static Eo *_instance;
+//TIZEN_ONLY(20210423): recover init failure
+static Ecore_Idler *_init_idler = NULL;
+//
 static int _init_count = 0;
 //TIZEN_ONLY(20171108): make atspi_proxy work
 static const char *_a11y_socket_address;
@@ -7129,12 +7132,38 @@ static void _bridge_object_register(Eo *bridge, Eo *obj)
    eina_hash_add(pd->cache, &obj, obj);
 }
 
+//TIZEN_ONLY(20210423): recover init failure
+static Eina_Bool
+_init_job(void *data)
+{
+   _instance = efl_add_ref(ELM_ATSPI_BRIDGE_CLASS, NULL);
+   _init_count++;
+
+   /* try to create bridge object 10 times */
+   if (_instance || _init_count > 10)
+     {
+        _init_idler = NULL;
+        return ECORE_CALLBACK_CANCEL;
+     }
+
+   return ECORE_CALLBACK_RENEW;
+}
+//
+
 void
 _elm_atspi_bridge_init(void)
 {
    if (!_init_count)
      {
         _instance = efl_add_ref(ELM_ATSPI_BRIDGE_CLASS, NULL);
+
+        //TIZEN_ONLY(20210423): recover init failure
+        if (!_instance)
+          {
+             _init_idler = ecore_idler_add(_init_job, NULL);
+          }
+        //
+
         _init_count = 1;
      }
 }
@@ -7150,6 +7179,9 @@ _elm_atspi_bridge_shutdown(void)
 {
    if (_init_count)
      {
+        //TIZEN_ONLY(20210423): recover init failure
+        if (_init_idler) ecore_idler_del(_init_idler);
+        //
         efl_unref(_instance);
         _init_count = 0;
         _instance = NULL;