Avoid memory corruption by cleaning up parts at the correct time.
authorrbdpngn <rbdpngn>
Tue, 25 Nov 2003 07:22:19 +0000 (07:22 +0000)
committerrbdpngn <rbdpngn@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Tue, 25 Nov 2003 07:22:19 +0000 (07:22 +0000)
SVN revision: 7942

legacy/edje/src/lib/edje_load.c
legacy/edje/src/lib/edje_private.h
legacy/edje/src/lib/edje_text.c
legacy/edje/src/lib/edje_util.c

index 0b36148b08466caa840597027387585ce3f191e2..33bef239edb488c1a9564615915917ee4c75f6b8 100644 (file)
@@ -432,7 +432,7 @@ _edje_file_del(Edje *ed)
        if (ed->collection->references <= 0)
          {
             ed->file->collection_hash = evas_hash_del(ed->file->collection_hash, ed->part, ed->collection);
-            _edje_collection_free(ed->collection);
+            _edje_collection_free(ed, ed->collection);
          }
        ed->collection = NULL;
      }
@@ -446,7 +446,7 @@ _edje_file_del(Edje *ed)
        while (ed->parts)
          {
             Edje_Real_Part *rp;
-            
+
             rp = ed->parts->data;
             ed->parts = evas_list_remove(ed->parts, rp);
             evas_object_event_callback_del(rp->object, 
@@ -467,8 +467,7 @@ _edje_file_del(Edje *ed)
             evas_object_event_callback_del(rp->object, 
                                            EVAS_CALLBACK_MOUSE_WHEEL,
                                            _edje_mouse_wheel_cb);
-            _edje_text_part_on_del(ed, rp);
-            _edje_color_class_on_del(ed, rp);
+            _edje_text_real_part_on_del(ed, rp);
             evas_object_del(rp->object);
             if (rp->swallowed_object)
               {
@@ -554,12 +553,12 @@ _edje_file_free(Edje_File *edf)
 }
 
 void
-_edje_collection_free(Edje_Part_Collection *ec)
+_edje_collection_free(Edje *ed, Edje_Part_Collection *ec)
 {
    while (ec->programs)
      {
        Edje_Program *pr;
-       
+
        pr = ec->programs->data;
        ec->programs = evas_list_remove(ec->programs, pr);
        if (pr->name) free(pr->name);
@@ -580,11 +579,17 @@ _edje_collection_free(Edje_Part_Collection *ec)
    while (ec->parts)
      {
        Edje_Part *ep;
-       
+
        ep = ec->parts->data;
        ec->parts = evas_list_remove(ec->parts, ep);
+       _edje_text_part_on_del(ed, ep);
+       _edje_color_class_on_del(ed, ep);
        if (ep->name) free(ep->name);
-       if (ep->default_desc) _edje_collection_free_part_description_free(ep->default_desc);
+       if (ep->default_desc)
+         {
+            _edje_collection_free_part_description_free(ep->default_desc);
+            ep->default_desc = NULL;
+         }
        while (ep->other_desc)
          {
             Edje_Part_Description *desc;
index 848e7b42c2efaf4f34e4264f9367890c326f4005..714de4eefd00ce14a9bcba10a0ce9dce1f8bb11a 100644 (file)
@@ -565,7 +565,7 @@ void  _edje_edd_setup(void);
 void  _edje_file_add(Edje *ed);
 void  _edje_file_del(Edje *ed);
 void  _edje_file_free(Edje_File *edf);
-void  _edje_collection_free(Edje_Part_Collection *ec);
+void  _edje_collection_free(Edje *ed, Edje_Part_Collection *ec);
 
 Edje *_edje_add(Evas_Object *obj);
 void  _edje_del(Edje *ed);
@@ -581,14 +581,15 @@ void  _edje_emit(Edje *ed, char *sig, char *src);
 void  _edje_text_init(void);
 void  _edje_text_part_on_add(Edje *ed, Edje_Real_Part *ep);
 void  _edje_text_part_on_add_clippers(Edje *ed, Edje_Real_Part *ep);
-void  _edje_text_part_on_del(Edje *ed, Edje_Real_Part *ep);
+void  _edje_text_part_on_del(Edje *ed, Edje_Part *ep);
+void  _edje_text_real_part_on_del(Edje *ed, Edje_Real_Part *ep);
 void  _edje_text_recalc_apply(Edje *ed, Edje_Real_Part *ep, Edje_Calc_Params *params, Edje_Part_Description *chosen_desc);
     
 Edje_Real_Part   *_edje_real_part_get(Edje *ed, char *part);
 Edje_Color_Class *_edje_color_class_find(Edje *ed, char *color_class);
 void              _edje_color_class_member_add(Edje *ed, char *color_class);
 void              _edje_color_class_member_del(Edje *ed, char *color_class);
-void              _edje_color_class_on_del(Edje *ed, Edje_Real_Part *rp);
+void              _edje_color_class_on_del(Edje *ed, Edje_Part *ep);
 Edje_Text_Class  *_edje_text_class_find(Edje *ed, char *text_class);
 void              _edje_text_class_member_add(Edje *ed, char *text_class);
 void              _edje_text_class_member_del(Edje *ed, char *text_class);
index 43acb5406eed9721fb99e67e4f13d06fd228c036..903214f385e0e7b950fcb95f2e1e415c9d84f3ae 100644 (file)
@@ -229,27 +229,41 @@ _edje_text_part_on_add_clippers(Edje *ed, Edje_Real_Part *ep)
 }
 
 void
-_edje_text_part_on_del(Edje *ed, Edje_Real_Part *ep)
+_edje_text_part_on_del(Edje *ed, Edje_Part *pt)
 {
    Evas_List *tmp;
-   Edje_Part *pt = ep->part;
 
-   while (ep->extra_objects)
+   if ((pt->default_desc) && (pt->default_desc->text.text_class))
      {
-       Evas_Object *o;
-       
-       o = ep->extra_objects->data;
-       ep->extra_objects = evas_list_remove(ep->extra_objects, o);
-       evas_object_del(o);
+        _edje_text_class_member_del(ed, pt->default_desc->text.text_class);
+       pt->default_desc->text.text_class = NULL;
      }
-
-   if ((pt->default_desc) && (pt->default_desc->text.text_class)) _edje_text_class_member_del(ed, pt->default_desc->text.text_class);
    for (tmp = pt->other_desc; tmp; tmp = tmp->next)
      {
         Edje_Part_Description *desc;
 
         desc = tmp->data;
-        if (desc->text.text_class) _edje_text_class_member_del(ed, desc->text.text_class);
+        if (desc->text.text_class)
+          {
+             _edje_text_class_member_del(ed, desc->text.text_class);
+             desc->text.text_class = NULL;
+          }
+     }
+   return;
+}
+
+void
+_edje_text_real_part_on_del(Edje *ed, Edje_Real_Part *ep)
+{
+   Evas_List *tmp;
+
+   while (ep->extra_objects)
+     {
+       Evas_Object *o;
+       
+       o = ep->extra_objects->data;
+       ep->extra_objects = evas_list_remove(ep->extra_objects, o);
+       evas_object_del(o);
      }
    return;
 }
index e45fc8d07febfe494d438d7e31639e86aa81c2ef..042b851a4e1fab86444446165524a479d075a8d4 100644 (file)
@@ -1054,10 +1054,9 @@ _edje_color_class_member_del(Edje *ed, char *color_class)
 }
 
 void
-_edje_color_class_on_del(Edje *ed, Edje_Real_Part *rp)
+_edje_color_class_on_del(Edje *ed, Edje_Part *ep)
 {
    Evas_List *tmp;
-   Edje_Part *ep = rp->part;
 
    if ((ep->default_desc) && (ep->default_desc->color_class)) _edje_color_class_member_del(ed, ep->default_desc->color_class);
    for (tmp = ep->other_desc; tmp; tmp = tmp->next)
@@ -1065,7 +1064,11 @@ _edje_color_class_on_del(Edje *ed, Edje_Real_Part *rp)
         Edje_Part_Description *desc;
 
        desc = tmp->data;
-       if (desc->color_class) _edje_color_class_member_del(ed, desc->color_class);
+       if (desc->color_class)
+         {
+            _edje_color_class_member_del(ed, desc->color_class);
+            desc->color_class = NULL;
+         }
      }
 }