be loud about deleting timers, idlers and events more than once.
authorbarbieri <barbieri@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Fri, 9 Jul 2010 14:52:45 +0000 (14:52 +0000)
committerbarbieri <barbieri@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Fri, 9 Jul 2010 14:52:45 +0000 (14:52 +0000)
git-svn-id: http://svn.enlightenment.org/svn/e/trunk/ecore@50158 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

src/lib/ecore/ecore_events.c
src/lib/ecore/ecore_idle_enterer.c
src/lib/ecore/ecore_idle_exiter.c
src/lib/ecore/ecore_idler.c
src/lib/ecore/ecore_timer.c

index 9746694..6c804d6 100644 (file)
@@ -156,6 +156,7 @@ ecore_event_handler_del(Ecore_Event_Handler *event_handler)
                         "ecore_event_handler_del");
        return NULL;
      }
+   EINA_SAFETY_ON_TRUE_RETURN_VAL(event_handler->delete_me, NULL);
    event_handler->delete_me = 1;
    event_handlers_delete_list = eina_list_append(event_handlers_delete_list, event_handler);
    return event_handler->data;
@@ -214,6 +215,7 @@ ecore_event_del(Ecore_Event *event)
        ECORE_MAGIC_FAIL(event, ECORE_MAGIC_EVENT, "ecore_event_del");
        return NULL;
      }
+   EINA_SAFETY_ON_TRUE_RETURN_VAL(event->delete_me, NULL);
    event->delete_me = 1;
    return event->data;
 }
@@ -289,6 +291,7 @@ ecore_event_filter_del(Ecore_Event_Filter *ef)
        ECORE_MAGIC_FAIL(ef, ECORE_MAGIC_EVENT_FILTER, "ecore_event_filter_del");
        return NULL;
      }
+   EINA_SAFETY_ON_TRUE_RETURN_VAL(ef->delete_me, NULL);
    ef->delete_me = 1;
    event_filters_delete_me = 1;
    return ef->data;
index 0eda1d0..ff92aa3 100644 (file)
@@ -89,6 +89,7 @@ ecore_idle_enterer_del(Ecore_Idle_Enterer *idle_enterer)
                         "ecore_idle_enterer_del");
        return NULL;
      }
+   EINA_SAFETY_ON_TRUE_RETURN_VAL(idle_enterer->delete_me, NULL);
    idle_enterer->delete_me = 1;
    idle_enterers_delete_me = 1;
    return idle_enterer->data;
index 9b8231f..b964919 100644 (file)
@@ -65,6 +65,7 @@ ecore_idle_exiter_del(Ecore_Idle_Exiter *idle_exiter)
                         "ecore_idle_exiter_del");
        return NULL;
      }
+   EINA_SAFETY_ON_TRUE_RETURN_VAL(idle_exiter->delete_me, NULL);
    idle_exiter->delete_me = 1;
    idle_exiters_delete_me = 1;
    return idle_exiter->data;
index e3269c3..52f1ae2 100644 (file)
@@ -73,6 +73,7 @@ ecore_idler_del(Ecore_Idler *idler)
                         "ecore_idler_del");
        return NULL;
      }
+   EINA_SAFETY_ON_TRUE_RETURN_VAL(idler->delete_me, NULL);
    idler->delete_me = 1;
    idlers_delete_me = 1;
    return idler->data;
index 9a49675..d7d847b 100644 (file)
@@ -190,9 +190,9 @@ ecore_timer_del(Ecore_Timer *timer)
        return data;
      }
 
-   if (timer->delete_me) return timer->data;
-   timers_delete_me++;
+   EINA_SAFETY_ON_TRUE_RETURN_VAL(timer->delete_me, NULL);
    timer->delete_me = 1;
+   timers_delete_me++;
    return timer->data;
 }
 
@@ -368,7 +368,7 @@ void
 _ecore_timer_cleanup(void)
 {
    Ecore_Timer *l;
-   int in_use = 0;
+   int in_use = 0, todo = timers_delete_me, done = 0;
 
    if (!timers_delete_me) return;
    for (l = timers; l;)
@@ -387,6 +387,7 @@ _ecore_timer_cleanup(void)
             ECORE_MAGIC_SET(timer, ECORE_MAGIC_NONE);
             free(timer);
             timers_delete_me--;
+            done++;
             if (timers_delete_me == 0) return;
          }
      }
@@ -406,14 +407,17 @@ _ecore_timer_cleanup(void)
             ECORE_MAGIC_SET(timer, ECORE_MAGIC_NONE);
             free(timer);
             timers_delete_me--;
+            done++;
             if (timers_delete_me == 0) return;
          }
      }
 
    if ((!in_use) && (timers_delete_me))
      {
-       ERR("%d timers to delete, but they were not found! reset counter.",
-           timers_delete_me);
+       ERR("%d timers to delete, but they were not found!"
+           "Stats: todo=%d, done=%d, pending=%d, in_use=%d. "
+           "reset counter.",
+           timers_delete_me, todo, done, todo - done, in_use);
        timers_delete_me = 0;
      }
 }