loop: Fix loop_get search priority
authorJean-Philippe Andre <jp.andre@samsung.com>
Wed, 20 Dec 2017 02:02:59 +0000 (11:02 +0900)
committerWonki Kim <wonki_.kim@samsung.com>
Wed, 10 Jan 2018 11:08:13 +0000 (20:08 +0900)
According to comments by @k-s & @raster.

See 784a5b56a3c798e5a8 this was intended to be a fallback, not the first
lookup indeed. Since this is an error case, let's print an ERR message
at least.

src/lib/ecore/efl_loop_consumer.c

index 389e0c5..f984909 100644 (file)
@@ -14,9 +14,14 @@ struct _Efl_Loop_Consumer_Data
 static Efl_Loop *
 _efl_loop_consumer_loop_get(Eo *obj, Efl_Loop_Consumer_Data *pd EINA_UNUSED)
 {
-   if (eina_main_loop_is())
-     return ecore_main_loop_get();
-   return efl_provider_find(obj, EFL_LOOP_CLASS);
+   Efl_Loop *loop = efl_provider_find(obj, EFL_LOOP_CLASS);
+   if (!loop && eina_main_loop_is())
+     {
+        loop = ecore_main_loop_get();
+        ERR("Failed to get the loop on object %p from the main thread! "
+            "Returning the main loop: %p", obj, loop);
+     }
+   return loop;
 }
 
 static void