raster pushed a commit to branch master.

http://git.enlightenment.org/core/elementary.git/commit/?id=7ec900f038c87a42e4414aa44add78301da5115f

commit 7ec900f038c87a42e4414aa44add78301da5115f
Author: Carsten Haitzler (Rasterman) <[email protected]>
Date:   Mon Feb 17 16:59:50 2014 +0900

    fix thread complaints in examples
---
 src/examples/efl_thread_4.c | 18 ++++++++++++++++--
 src/examples/efl_thread_5.c | 17 ++++++++++++++---
 2 files changed, 30 insertions(+), 5 deletions(-)

diff --git a/src/examples/efl_thread_4.c b/src/examples/efl_thread_4.c
index 268a70c..63b27e8 100644
--- a/src/examples/efl_thread_4.c
+++ b/src/examples/efl_thread_4.c
@@ -83,6 +83,17 @@ down(void *data, Evas *e, Evas_Object *obj, void *event_info)
    pthread_mutex_unlock(&th_lock);
 }
 
+// on window delete - cancel thread then delete window and exit mainloop
+static void
+del(void *data, Evas_Object *obj, void *event_info)
+{
+   pthread_mutex_lock(&th_lock);
+   th_exit = 1;
+   pthread_mutex_unlock(&th_lock);
+   evas_object_del(obj);
+   elm_exit();
+}
+
 EAPI_MAIN int
 elm_main(int argc, char **argv)
 {
@@ -91,8 +102,8 @@ elm_main(int argc, char **argv)
    elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
 
    win = elm_win_util_standard_add("efl-thread-4", "EFL Thread 4");
-   elm_win_autodel_set(win, EINA_TRUE);
-
+   evas_object_smart_callback_add(win, "delete,request", del, NULL);
+   
    o = evas_object_rectangle_add(evas_object_evas_get(win));
    evas_object_color_set(o, 50, 80, 180, 255);
    evas_object_resize(o, 100, 100);
@@ -109,6 +120,9 @@ elm_main(int argc, char **argv)
    evas_object_show(win);
 
    elm_run();
+   pthread_mutex_lock(&th_lock);
+   th_exit = 1;
+   pthread_mutex_unlock(&th_lock);
    elm_shutdown();
 
    return 0;
diff --git a/src/examples/efl_thread_5.c b/src/examples/efl_thread_5.c
index 8c75ec9..13d28be 100644
--- a/src/examples/efl_thread_5.c
+++ b/src/examples/efl_thread_5.c
@@ -60,7 +60,18 @@ static void th_cancel(void *data, Ecore_Thread *th) { 
printf("thread cancelled\n
 static void
 down(void *data, Evas *e, Evas_Object *obj, void *event_info)
 {
-   ecore_thread_cancel(thr);
+   if (thr) ecore_thread_cancel(thr);
+   thr = NULL;
+}
+
+// on window delete - cancel thread then delete window and exit mainloop
+static void
+del(void *data, Evas_Object *obj, void *event_info)
+{
+   if (thr) ecore_thread_cancel(thr);
+   thr = NULL;
+   evas_object_del(obj);
+   elm_exit();
 }
 
 EAPI_MAIN int
@@ -71,7 +82,7 @@ elm_main(int argc, char **argv)
    elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
 
    win = elm_win_util_standard_add("efl-thread-5", "EFL Thread 5");
-   elm_win_autodel_set(win, EINA_TRUE);
+   evas_object_smart_callback_add(win, "delete,request", del, NULL);
 
    o = evas_object_rectangle_add(evas_object_evas_get(win));
    evas_object_color_set(o, 50, 80, 180, 255);
@@ -94,7 +105,7 @@ elm_main(int argc, char **argv)
    evas_object_show(win);
 
    elm_run();
-   ecore_thread_cancel(thr);
+   if (thr) ecore_thread_cancel(thr);
    elm_shutdown();
 
    return 0;

-- 


Reply via email to