summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMike Blumenkrantz <m.blumenkran@samsung.com>2013-06-18 10:58:52 +0100
committerMike Blumenkrantz <m.blumenkran@samsung.com>2013-06-18 15:44:37 +0100
commit720303b53b42cff414ea9aad24141b0f37d5932a (patch)
treedcee5401d879c2a76fa8f4575ea3c26c138e49c2 /src
parent527e5ef49a9923f002d7ffaf0510e561e2fdc88f (diff)
add E_EVENT_EXEC_NEW and E_EVENT_EXEC_DEL, also prevent deleted exec watchers from being called repeatedly
Diffstat (limited to 'src')
-rw-r--r--src/bin/e_exec.c60
-rw-r--r--src/bin/e_exec.h8
2 files changed, 55 insertions, 13 deletions
diff --git a/src/bin/e_exec.c b/src/bin/e_exec.c
index e5fd13467..1b406c934 100644
--- a/src/bin/e_exec.c
+++ b/src/bin/e_exec.c
@@ -50,7 +50,9 @@ struct _E_Config_Dialog_Data
50static E_Exec_Instance *_e_exec_cb_exec(void *data, Efreet_Desktop *desktop, char *exec, int remaining); 50static E_Exec_Instance *_e_exec_cb_exec(void *data, Efreet_Desktop *desktop, char *exec, int remaining);
51static Eina_Bool _e_exec_cb_expire_timer(void *data); 51static Eina_Bool _e_exec_cb_expire_timer(void *data);
52static Eina_Bool _e_exec_cb_exit(void *data, int type, void *event); 52static Eina_Bool _e_exec_cb_exit(void *data, int type, void *event);
53 53static void _e_exec_cb_exec_new_free(void *data, void *event);
54static void _e_exec_cb_exec_del_free(void *data, void *event);
55static void _e_exe_instance_watchers_call(E_Exec_Instance *inst, E_Exec_Watch_Type type);
54static Eina_Bool _e_exec_startup_id_pid_find(const Eina_Hash *hash __UNUSED__, const void *key __UNUSED__, void *value, void *data); 56static Eina_Bool _e_exec_startup_id_pid_find(const Eina_Hash *hash __UNUSED__, const void *key __UNUSED__, void *value, void *data);
55 57
56static void _e_exec_error_dialog(Efreet_Desktop *desktop, const char *exec, Ecore_Exe_Event_Del *event, Ecore_Exe_Event_Data *error, Ecore_Exe_Event_Data *read); 58static void _e_exec_error_dialog(Efreet_Desktop *desktop, const char *exec, Ecore_Exe_Event_Del *event, Ecore_Exe_Event_Data *error, Ecore_Exe_Event_Data *read);
@@ -74,6 +76,9 @@ static Ecore_Event_Handler *_e_exec_border_add_handler = NULL;
74static E_Exec_Instance *(*_e_exec_executor_func)(void *data, E_Zone * zone, Efreet_Desktop * desktop, const char *exec, Eina_List *files, const char *launch_method) = NULL; 76static E_Exec_Instance *(*_e_exec_executor_func)(void *data, E_Zone * zone, Efreet_Desktop * desktop, const char *exec, Eina_List *files, const char *launch_method) = NULL;
75static void *_e_exec_executor_data = NULL; 77static void *_e_exec_executor_data = NULL;
76 78
79EAPI int E_EVENT_EXEC_NEW = -1;
80EAPI int E_EVENT_EXEC_DEL = -1;
81
77/* externally accessible functions */ 82/* externally accessible functions */
78EINTERN int 83EINTERN int
79e_exec_init(void) 84e_exec_init(void)
@@ -86,6 +91,9 @@ e_exec_init(void)
86 _e_exec_border_add_handler = 91 _e_exec_border_add_handler =
87 ecore_event_handler_add(E_EVENT_BORDER_ADD, _e_exec_cb_event_border_add, NULL); 92 ecore_event_handler_add(E_EVENT_BORDER_ADD, _e_exec_cb_event_border_add, NULL);
88#endif 93#endif
94
95 E_EVENT_EXEC_NEW = ecore_event_type_new();
96 E_EVENT_EXEC_DEL = ecore_event_type_new();
89 return 1; 97 return 1;
90} 98}
91 99
@@ -210,6 +218,8 @@ e_exec_phony_del(E_Exec_Instance *inst)
210{ 218{
211 if (!inst) return; 219 if (!inst) return;
212 EINA_SAFETY_ON_TRUE_RETURN(!inst->phony); 220 EINA_SAFETY_ON_TRUE_RETURN(!inst->phony);
221 inst->ref--;
222 _e_exe_instance_watchers_call(inst, E_EXEC_WATCH_STOPPED);
213 _e_exec_instance_free(inst); 223 _e_exec_instance_free(inst);
214} 224}
215 225
@@ -220,6 +230,7 @@ e_exec_phony(E_Border *bd)
220 Eina_List *l, *lnew; 230 Eina_List *l, *lnew;
221 231
222 inst = E_NEW(E_Exec_Instance, 1); 232 inst = E_NEW(E_Exec_Instance, 1);
233 inst->ref = 1;
223 inst->phony = 1; 234 inst->phony = 1;
224 inst->desktop = bd->desktop; 235 inst->desktop = bd->desktop;
225 if (bd->desktop) 236 if (bd->desktop)
@@ -260,6 +271,8 @@ e_exec_phony(E_Border *bd)
260 lnew = eina_list_append(l, inst); 271 lnew = eina_list_append(l, inst);
261 if (l) eina_hash_modify(e_exec_instances, inst->key, lnew); 272 if (l) eina_hash_modify(e_exec_instances, inst->key, lnew);
262 else eina_hash_add(e_exec_instances, inst->key, lnew); 273 else eina_hash_add(e_exec_instances, inst->key, lnew);
274 inst->ref++;
275 ecore_event_add(E_EVENT_EXEC_NEW, inst, _e_exec_cb_exec_new_free, inst);
263 return inst; 276 return inst;
264} 277}
265 278
@@ -305,13 +318,13 @@ _e_exe_instance_watchers_call(E_Exec_Instance *inst, E_Exec_Watch_Type type)
305 E_Exec_Watch *iw; 318 E_Exec_Watch *iw;
306 Eina_List *l, *ln; 319 Eina_List *l, *ln;
307 320
308 inst->walking++; 321 inst->ref++;
309 EINA_LIST_FOREACH(inst->watchers, l, iw) 322 EINA_LIST_FOREACH(inst->watchers, l, iw)
310 { 323 {
311 if (iw->func) iw->func((void *)(iw->data), inst, type); 324 if (iw->func && (!iw->delete_me)) iw->func((void *)(iw->data), inst, type);
312 } 325 }
313 inst->walking--; 326 inst->ref--;
314 if (inst->walking == 0) 327 if (inst->ref == 0)
315 { 328 {
316 EINA_LIST_FOREACH_SAFE(inst->watchers, l, ln, iw) 329 EINA_LIST_FOREACH_SAFE(inst->watchers, l, ln, iw)
317 { 330 {
@@ -353,7 +366,7 @@ e_exec_instance_watcher_del(E_Exec_Instance *inst, void (*func)(void *data, E_Ex
353 { 366 {
354 if ((iw->func == func) && (iw->data == data)) 367 if ((iw->func == func) && (iw->data == data))
355 { 368 {
356 if (inst->walking == 0) 369 if (inst->ref == 0)
357 { 370 {
358 inst->watchers = eina_list_remove_list(inst->watchers, l); 371 inst->watchers = eina_list_remove_list(inst->watchers, l);
359 free(iw); 372 free(iw);
@@ -382,6 +395,7 @@ _e_exec_cb_exec(void *data, Efreet_Desktop *desktop, char *exec, int remaining)
382 launch = data; 395 launch = data;
383 inst = E_NEW(E_Exec_Instance, 1); 396 inst = E_NEW(E_Exec_Instance, 1);
384 if (!inst) return NULL; 397 if (!inst) return NULL;
398 inst->ref = 1;
385 399
386 if (startup_id == 0) 400 if (startup_id == 0)
387 { 401 {
@@ -587,6 +601,8 @@ _e_exec_cb_exec(void *data, Efreet_Desktop *desktop, char *exec, int remaining)
587 free(launch); 601 free(launch);
588 } 602 }
589 free(exec); 603 free(exec);
604 inst->ref++;
605 ecore_event_add(E_EVENT_EXEC_NEW, inst, _e_exec_cb_exec_new_free, inst);
590 return inst; 606 return inst;
591} 607}
592 608
@@ -608,12 +624,9 @@ static void
608_e_exec_instance_free(E_Exec_Instance *inst) 624_e_exec_instance_free(E_Exec_Instance *inst)
609{ 625{
610 Eina_List *instances; 626 Eina_List *instances;
611 E_Exec_Watch *iw;
612
613 _e_exe_instance_watchers_call(inst, E_EXEC_WATCH_STOPPED);
614 EINA_LIST_FREE(inst->watchers, iw)
615 free(iw);
616 627
628 if (inst->ref) return;
629 E_FREE_LIST(inst->watchers, free);
617 if (inst->key) 630 if (inst->key)
618 { 631 {
619 instances = eina_hash_find(e_exec_instances, inst->key); 632 instances = eina_hash_find(e_exec_instances, inst->key);
@@ -625,7 +638,13 @@ _e_exec_instance_free(E_Exec_Instance *inst)
625 else 638 else
626 eina_hash_del_by_key(e_exec_instances, inst->key); 639 eina_hash_del_by_key(e_exec_instances, inst->key);
627 } 640 }
628 eina_stringshare_del(inst->key); 641 eina_stringshare_replace(&inst->key, NULL);
642 }
643 if (!inst->deleted)
644 {
645 inst->deleted = 1;
646 ecore_event_add(E_EVENT_EXEC_DEL, inst, _e_exec_cb_exec_del_free, inst);
647 return;
629 } 648 }
630 if (inst->desktop) 649 if (inst->desktop)
631 e_exec_start_pending = eina_list_remove(e_exec_start_pending, 650 e_exec_start_pending = eina_list_remove(e_exec_start_pending,
@@ -649,6 +668,21 @@ _e_exec_instance_free(E_Exec_Instance *inst)
649 } 668 }
650 */ 669 */
651 670
671static void
672_e_exec_cb_exec_new_free(void *data, void *ev EINA_UNUSED)
673{
674 E_Exec_Instance *inst = data;
675
676 inst->ref--;
677 _e_exec_instance_free(inst);
678}
679
680static void
681_e_exec_cb_exec_del_free(void *data, void *ev EINA_UNUSED)
682{
683 _e_exec_instance_free(data);
684}
685
652static Eina_Bool 686static Eina_Bool
653_e_exec_cb_exit(void *data __UNUSED__, int type __UNUSED__, void *event) 687_e_exec_cb_exit(void *data __UNUSED__, int type __UNUSED__, void *event)
654{ 688{
@@ -731,6 +765,8 @@ _e_exec_cb_exit(void *data __UNUSED__, int type __UNUSED__, void *event)
731 } 765 }
732 else 766 else
733 */ 767 */
768 inst->ref--;
769 _e_exe_instance_watchers_call(inst, E_EXEC_WATCH_STOPPED);
734 _e_exec_instance_free(inst); 770 _e_exec_instance_free(inst);
735 771
736 return ECORE_CALLBACK_PASS_ON; 772 return ECORE_CALLBACK_PASS_ON;
diff --git a/src/bin/e_exec.h b/src/bin/e_exec.h
index 89e182611..fefaaa73b 100644
--- a/src/bin/e_exec.h
+++ b/src/bin/e_exec.h
@@ -18,9 +18,10 @@ struct _E_Exec_Instance
18 int screen; 18 int screen;
19 int desk_x, desk_y; 19 int desk_x, desk_y;
20 int used; 20 int used;
21 int walking; 21 int ref;
22 Eina_List *watchers; 22 Eina_List *watchers;
23 Eina_Bool phony : 1; 23 Eina_Bool phony : 1;
24 Eina_Bool deleted : 1;
24}; 25};
25 26
26typedef enum 27typedef enum
@@ -43,5 +44,10 @@ EAPI void e_exec_instance_found(E_Exec_Instance *inst);
43EAPI void e_exec_instance_watcher_add(E_Exec_Instance *inst, void (*func) (void *data, E_Exec_Instance *inst, E_Exec_Watch_Type type), const void *data); 44EAPI void e_exec_instance_watcher_add(E_Exec_Instance *inst, void (*func) (void *data, E_Exec_Instance *inst, E_Exec_Watch_Type type), const void *data);
44EAPI void e_exec_instance_watcher_del(E_Exec_Instance *inst, void (*func) (void *data, E_Exec_Instance *inst, E_Exec_Watch_Type type), const void *data); 45EAPI void e_exec_instance_watcher_del(E_Exec_Instance *inst, void (*func) (void *data, E_Exec_Instance *inst, E_Exec_Watch_Type type), const void *data);
45EAPI const Eina_List *e_exec_desktop_instances_find(const Efreet_Desktop *desktop); 46EAPI const Eina_List *e_exec_desktop_instances_find(const Efreet_Desktop *desktop);
47
48/* sends E_Exec_Instance */
49EAPI extern int E_EVENT_EXEC_NEW;
50EAPI extern int E_EVENT_EXEC_DEL;
51
46#endif 52#endif
47#endif 53#endif