[UI Thread] Use thread default context 74/270474/11
authorHwankyu Jhun <h.jhun@samsung.com>
Thu, 3 Feb 2022 06:43:34 +0000 (15:43 +0900)
committerHwanKyu Jhun <h.jhun@samsung.com>
Tue, 22 Mar 2022 08:25:52 +0000 (08:25 +0000)
If the process sets the thread default context, the ecore main loop uses
it instead of the global default context.

Change-Id: Icf01d6098ad3c3c9e82d5fbf8045c45e85877928
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
src/lib/ecore/ecore_glib.c
src/lib/ecore/ecore_main.c

index d0d4004..dea98ff 100644 (file)
@@ -239,7 +239,13 @@ _ecore_glib_select(int             ecore_fds,
    GMainContext *ctx;
    int ret;
 
-   ctx = g_main_context_default();
+   //TIZEN_ONLY(220322): Use thread default context
+   /* If a process sets the thread default context using the g_main_context_push_thread_default(),
+    * this function uses thread default context instead of the global default context.
+    */
+   ctx = g_main_context_get_thread_default();
+   if (!ctx)
+     ctx = g_main_context_default();
 
    while (!g_main_context_acquire(ctx))
      g_thread_yield();
index 7cacca1..0e2d947 100644 (file)
@@ -1304,8 +1304,14 @@ _ecore_main_loop_begin(Eo *obj, Efl_Loop_Data *pd)
 #else
              if (!pd->do_quit)
                {
-                  if (!ecore_main_loop)
-                    ecore_main_loop = g_main_loop_new(NULL, FALSE);
+                  //TIZEN_ONLY(220322): Use thread default context
+                  /* If a process sets the thread default context using the g_main_context_push_thread_default(),
+                   * this function uses thread default context instead of the global default context.
+                   */
+                  if (!ecore_main_loop) {
+                    ecore_main_loop = g_main_loop_new(
+                        g_main_context_get_thread_default(), FALSE);
+                  }
                   g_main_loop_run(ecore_main_loop);
                }
              pd->do_quit = 0;
@@ -1339,8 +1345,14 @@ _ecore_main_loop_begin(Eo *obj, Efl_Loop_Data *pd)
 #else
         if (!pd->do_quit)
           {
-             if (!ecore_main_loop)
-               ecore_main_loop = g_main_loop_new(NULL, 1);
+             //TIZEN_ONLY(220322): Use thread default context
+             /* If a process sets the thread default context using the g_main_context_push_thread_default(),
+              * this function uses thread default context instead of the global default context.
+              */
+             if (!ecore_main_loop) {
+               ecore_main_loop = g_main_loop_new(
+                  g_main_context_get_thread_default(), 1);
+             }
              g_main_loop_run(ecore_main_loop);
           }
         pd->do_quit = 0;