evas: better patch for preventing infinite loop.
authorcedric <cedric@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Wed, 20 Jul 2011 09:14:41 +0000 (09:14 +0000)
committercedric <cedric@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Wed, 20 Jul 2011 09:14:41 +0000 (09:14 +0000)
git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/evas@61520 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

src/lib/canvas/evas_object_smart.c

index 9058e91..45858b1 100644 (file)
@@ -531,6 +531,14 @@ evas_object_smart_need_recalculate_set(Evas_Object *obj, Eina_Bool value)
    value = !!value;
    if (o->need_recalculate == value)
      return;
+
+   if (obj->recalculate_cycle > 64)
+     {
+        ERR("Object %p is not stable during recalc loop", obj);
+        return ;
+     }
+   if (obj->layer->evas->in_smart_calc)
+     obj->recalculate_cycle++;
    o->need_recalculate = value;
 
    if (!obj->smart.smart->smart_class->calculate) return;
@@ -600,31 +608,32 @@ void
 evas_call_smarts_calculate(Evas *e)
 {
    Eina_Array *calculate;
+   Evas_Object *obj;
+   Eina_Array_Iterator it;
    unsigned int i;
-   static int in_smart_calc = 0;
 
-   in_smart_calc++;
+   e->in_smart_calc++;
    calculate = &e->calculate_objects;
-   for (i = 0; i < calculate->count; i++)
+   EINA_ARRAY_ITER_NEXT(calculate, i, obj, it)
      {
-        Evas_Object *obj;
         Evas_Object_Smart *o;
-        int before;
 
-        obj = eina_array_data_get(calculate, i);
         if (obj->delete_me)
           continue;
 
-        before = calculate->count;
         o = obj->object_data;
         if (o->need_recalculate)
           {
-             obj->smart.smart->smart_class->calculate(obj);
              o->need_recalculate = 0;
+             obj->smart.smart->smart_class->calculate(obj);
           }
      }
-   in_smart_calc--;
-   if (in_smart_calc == 0) eina_array_flush(calculate);
+   EINA_ARRAY_ITER_NEXT(calculate, i, obj, it)
+     {
+        obj->recalculate_cycle = 0;
+     }
+   e->in_smart_calc--;
+   if (e->in_smart_calc == 0) eina_array_clean(calculate);
 }
 
 EAPI void