summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorVincent Torri <vincent dot torri at gmail dot com>2015-09-25 07:32:32 +0200
committerCedric BAIL <cedric@osg.samsung.com>2015-10-12 17:21:59 -0700
commit0f4060e8a96a62eeaa03b9ca1998c7836b5488ca (patch)
treeaec5974e2217b2beca43e484b62d4d782cf48091 /src/lib
parent506092bedaaee5974ee68c9a252a73df3f1e863e (diff)
ecore: mimic Win32 handlers deletion with Fd ones
Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/ecore/ecore_main.c56
1 files changed, 30 insertions, 26 deletions
diff --git a/src/lib/ecore/ecore_main.c b/src/lib/ecore/ecore_main.c
index e35241de6e..d7f253e3a2 100644
--- a/src/lib/ecore/ecore_main.c
+++ b/src/lib/ecore/ecore_main.c
@@ -239,7 +239,7 @@ static Ecore_Fd_Handler *fd_handlers_to_call_current;
239#ifdef _WIN32 239#ifdef _WIN32
240static Ecore_Win32_Handler *win32_handlers = NULL; 240static Ecore_Win32_Handler *win32_handlers = NULL;
241static Ecore_Win32_Handler *win32_handler_current = NULL; 241static Ecore_Win32_Handler *win32_handler_current = NULL;
242static Eina_Bool win32_handlers_delete_me = EINA_FALSE; 242static Eina_List *win32_handlers_to_delete = NULL;
243#endif 243#endif
244 244
245#ifdef _WIN32 245#ifdef _WIN32
@@ -1126,7 +1126,7 @@ ecore_main_win32_handler_add(void *h,
1126 EINA_MAIN_LOOP_CHECK_RETURN_VAL(NULL); 1126 EINA_MAIN_LOOP_CHECK_RETURN_VAL(NULL);
1127 if (!h || !func) return NULL; 1127 if (!h || !func) return NULL;
1128 1128
1129 wh = calloc(1, sizeof(Ecore_Win32_Handler)); 1129 wh = ecore_win32_handler_calloc(1);
1130 if (!wh) return NULL; 1130 if (!wh) return NULL;
1131 ECORE_MAGIC_SET(wh, ECORE_MAGIC_WIN32_HANDLER); 1131 ECORE_MAGIC_SET(wh, ECORE_MAGIC_WIN32_HANDLER);
1132 wh->h = (HANDLE)h; 1132 wh->h = (HANDLE)h;
@@ -1183,8 +1183,13 @@ ecore_main_win32_handler_del(Ecore_Win32_Handler *win32_handler)
1183 "ecore_main_win32_handler_del"); 1183 "ecore_main_win32_handler_del");
1184 return NULL; 1184 return NULL;
1185 } 1185 }
1186 if (win32_handler->delete_me)
1187 {
1188 ERR("win32 handler %p deleted twice", win32_handler);
1189 return NULL;
1190 }
1186 win32_handler->delete_me = EINA_TRUE; 1191 win32_handler->delete_me = EINA_TRUE;
1187 win32_handlers_delete_me = EINA_TRUE; 1192 win32_handlers_to_delete = eina_list_append(win32_handlers_to_delete, win32_handler);
1188 return win32_handler->data; 1193 return win32_handler->data;
1189} 1194}
1190 1195
@@ -1332,9 +1337,11 @@ _ecore_main_shutdown(void)
1332 win32_handlers = (Ecore_Win32_Handler *)eina_inlist_remove(EINA_INLIST_GET(win32_handlers), 1337 win32_handlers = (Ecore_Win32_Handler *)eina_inlist_remove(EINA_INLIST_GET(win32_handlers),
1333 EINA_INLIST_GET(wh)); 1338 EINA_INLIST_GET(wh));
1334 ECORE_MAGIC_SET(wh, ECORE_MAGIC_NONE); 1339 ECORE_MAGIC_SET(wh, ECORE_MAGIC_NONE);
1335 free(wh); 1340 ecore_win32_handler_mp_free(wh);
1336 } 1341 }
1337 win32_handlers_delete_me = EINA_FALSE; 1342 if (win32_handlers_to_delete)
1343 win32_handlers_to_delete = eina_list_free(win32_handlers_to_delete);
1344 win32_handlers_to_delete = NULL;
1338 win32_handler_current = NULL; 1345 win32_handler_current = NULL;
1339#endif 1346#endif
1340} 1347}
@@ -1618,31 +1625,28 @@ static void
1618_ecore_main_win32_handlers_cleanup(void) 1625_ecore_main_win32_handlers_cleanup(void)
1619{ 1626{
1620 Ecore_Win32_Handler *wh; 1627 Ecore_Win32_Handler *wh;
1621 Eina_Inlist *l; 1628 Eina_List *l;
1622 int deleted_in_use = 0; 1629 Eina_List *l2;
1623 1630
1624 if (!win32_handlers_delete_me) return; 1631 if (!win32_handlers_to_delete) return;
1625 for (l = EINA_INLIST_GET(win32_handlers); l; ) 1632 EINA_LIST_FOREACH_SAFE(win32_handlers_to_delete, l, l2, wh)
1626 { 1633 {
1627 wh = (Ecore_Win32_Handler *)l; 1634 printf(" -- %s 1 : wh %p\n", __FUNCTION__, wh);
1628 1635 if (!wh)
1629 l = l->next;
1630 if (wh->delete_me)
1631 { 1636 {
1632 if (wh->references) 1637 win32_handlers_to_delete = eina_list_remove_list(l, win32_handlers_to_delete);
1633 { 1638 continue;
1634 deleted_in_use++;
1635 continue;
1636 }
1637
1638 win32_handlers = (Ecore_Win32_Handler *)
1639 eina_inlist_remove(EINA_INLIST_GET(win32_handlers),
1640 EINA_INLIST_GET(wh));
1641 ECORE_MAGIC_SET(wh, ECORE_MAGIC_NONE);
1642 free(wh);
1643 } 1639 }
1640 /* wh->delete_me should be set for all whs at the start of the list */
1641 if (wh->references)
1642 continue;
1643 win32_handlers = (Ecore_Win32_Handler *)
1644 eina_inlist_remove(EINA_INLIST_GET(win32_handlers), EINA_INLIST_GET(wh));
1645 ECORE_MAGIC_SET(wh, ECORE_MAGIC_NONE);
1646 printf(" -- %s 2 : wh %p\n", __FUNCTION__, wh);
1647 ecore_win32_handler_mp_free(wh);
1648 win32_handlers_to_delete = eina_list_remove_list(win32_handlers_to_delete, l);
1644 } 1649 }
1645 if (!deleted_in_use) win32_handlers_delete_me = EINA_FALSE;
1646} 1650}
1647 1651
1648#endif 1652#endif
@@ -2277,7 +2281,7 @@ _ecore_main_win32_select(int nfds EINA_UNUSED,
2277 if (!wh->func(wh->data, wh)) 2281 if (!wh->func(wh->data, wh))
2278 { 2282 {
2279 wh->delete_me = EINA_TRUE; 2283 wh->delete_me = EINA_TRUE;
2280 win32_handlers_delete_me = EINA_TRUE; 2284 win32_handlers_to_delete = eina_list_append(win32_handlers_to_delete, wh);
2281 } 2285 }
2282 wh->references--; 2286 wh->references--;
2283 } 2287 }