Enlightenment CVS committal

Author  : davemds
Project : e17
Module  : libs/edje

Dir     : e17/libs/edje/src/lib


Modified Files:
        edje_edit.c 


Log Message:
 * fixed strings free

===================================================================
RCS file: /cvs/e/e17/libs/edje/src/lib/edje_edit.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -3 -r1.5 -r1.6
--- edje_edit.c 6 Mar 2008 19:48:11 -0000       1.5
+++ edje_edit.c 8 Mar 2008 23:11:32 -0000       1.6
@@ -216,11 +216,10 @@
       rp->swallowed_object = NULL;
    }
    
-   /*if (rp->text.text) evas_stringshare_del(rp->text.text);
+   if (rp->text.text) evas_stringshare_del(rp->text.text);
    if (rp->text.font) evas_stringshare_del(rp->text.font);
    if (rp->text.cache.in_str) evas_stringshare_del(rp->text.cache.in_str);
    if (rp->text.cache.out_str) evas_stringshare_del(rp->text.cache.out_str);
-   TODO FIXME */
    
    if (rp->custom.description)
    {
@@ -548,6 +547,18 @@
    //printf("\n");
 }
 
+static void
+_edje_if_string_free(Edje *ed, const char *str)
+{
+   Eet_Dictionary *dict;
+   
+   if (!ed || !str) return;
+   
+   dict = eet_dictionary_get(ed->file->ef);
+   if (eet_dictionary_string_check(dict ,str)) return;
+   evas_stringshare_del(str);
+   str = NULL;
+}
 /*****************/
 /*  GENERAL API  */
 /*****************/
@@ -636,7 +647,7 @@
    
    /* Init Edje_Part_Collection */
    pc->id = id;
-   pc->references = 1;  //TODO i'm not shure about this (maybe 1 ?)
+   pc->references = 1;  //TODO i'm not shure about this (maybe set to 0 ?)
    pc->programs = NULL;
    pc->parts = NULL;
    pc->data = NULL;
@@ -764,11 +775,15 @@
       Edje_Part_Collection_Directory_Entry *pce = l->data;
       if (pc->id == pce->id)
       {
-         //if (pce->entry) free(pce->entry); //TODO Also this cause segv
-         pce->entry = mem_strdup(new_name);
-         
-         //ed->file->collection_hash = 
evas_hash_del(ed->file->collection_hash, pc->entry, edc);
-         //ed->file->collection_hash = 
evas_hash_add(ed->file->collection_hash, name, pc);
+         ed->file->collection_hash = evas_hash_del(ed->file->collection_hash,
+                                                   pce->entry, NULL);
+         ed->file->collection_hash = evas_hash_add(ed->file->collection_hash,
+                                                   new_name, pc);
+
+         //if (pce->entry &&  //TODO Also this cause segv
+         //    !eet_dictionary_string_check(eet_dictionary_get(ed->file->ef), 
pce->entry))
+         //   evas_stringshare_del(pce->entry);
+         pce->entry = evas_stringshare_add(new_name);
          
          return;
       }
@@ -871,7 +886,7 @@
    
    printf("Set name of part: %s [new name: %s]\n", part, new_name);
    
-   //if (rp->part->name && ed->file->free_strings) 
evas_stringshare_del(rp->part->name);  TODO FIXME
+   _edje_if_string_free(ed, rp->part->name);
    rp->part->name = (char *)evas_stringshare_add(new_name);
    
    return 1;
@@ -1065,7 +1080,7 @@
    _edje_fix_parts_id(ed);
    
    /* Free Edje_Part and all descriptions */
-   //if (ep->name  && ed->file->free_strings) evas_stringshare_del(ep->name); 
TODO FIXME
+   _edje_if_string_free(ed, ep->name);
    if (ep->default_desc)
    {
       _edje_collection_free_part_description_free(ep->default_desc);
@@ -1327,12 +1342,7 @@
    
    printf("Set source for part: %s [source: %s]\n", part, source);
    
-   if (rp->part->source)
-   {
-      //if (ed->file->free_strings)
-      //   evas_stringshare_del(rp->part->source); TODO FIXME
-      rp->part->source = NULL;
-   }
+   _edje_if_string_free(ed, rp->part->source);
    
    if (source)
       rp->part->source = evas_stringshare_add(source);
@@ -1412,15 +1422,15 @@
              !strcmp(epr->state, pd->state.name) &&
              pd->state.value == epr->value)
          {
-            //TODO free epr->state
-            epr->state = mem_strdup(new_name);
+            _edje_if_string_free(ed, epr->state);
+            epr->state = evas_stringshare_add(new_name);
             epr->value = value;
          }
       }
    }
    
    /* set name */
-   //if (pd->state.name && ed->file->free_strings) 
evas_stringshare_del(pd->state.name); TODO FIXME
+   _edje_if_string_free(ed, pd->state.name);
    pd->state.name = (char *)evas_stringshare_add(new_name);
    /* set value */
    pd->state.value = value;
@@ -2070,9 +2080,7 @@
    
    if (!text) return;
    
-   //if (pd->text.text && ed->file->free_strings)
-   //   evas_stringshare_del(pd->text.text); TODO FIXME
-   
+   _edje_if_string_free(ed, pd->text.text);
    pd->text.text = (char *)evas_stringshare_add(text);
     
    edje_object_calc_force(obj);
@@ -2297,7 +2305,7 @@
    GET_PD_OR_RETURN()
    printf("SET FONT of state: %s [%s]\n", state, font);
    
-   //if (pd->text.font && ed->file->free_strings) 
evas_stringshare_del(pd->text.font); TODO FIXME
+   _edje_if_string_free(ed, pd->text.font);
    pd->text.font = (char *)evas_stringshare_add(font);
     
    edje_object_calc_force(obj);
@@ -2656,14 +2664,12 @@
    pc->programs = evas_list_remove(pc->programs, epr);
    
    //Free Edje_Program
-   /*if (ed->file->free_strings)
-   {
-      if (epr->name) evas_stringshare_del(epr->name);
-      if (epr->signal) evas_stringshare_del(epr->signal);
-      if (epr->source) evas_stringshare_del(epr->source);
-      if (epr->state) evas_stringshare_del(epr->state);
-      if (epr->state2) evas_stringshare_del(epr->state2);
-   } TODO FIXME*/
+   _edje_if_string_free(ed, epr->name);
+   _edje_if_string_free(ed, epr->signal);
+   _edje_if_string_free(ed, epr->source);
+   _edje_if_string_free(ed, epr->state);
+   _edje_if_string_free(ed, epr->state2);
+
    while (epr->targets)
    {
       Edje_Program_Target *prt;
@@ -2785,7 +2791,7 @@
       
    printf("SET NAME for program: %s [new name: %s]\n", prog, new_name);
    
-   //if (epr->name && ed->file->free_strings) evas_stringshare_del(epr->name); 
TODO FIXME
+   _edje_if_string_free(ed, epr->name);
    epr->name = evas_stringshare_add(new_name);
    
    return 1;
@@ -2810,7 +2816,7 @@
    
    printf("SET SOURCE for program: %s [%s]\n", prog, source);
    
-   //if (epr->source && ed->file->free_strings) 
evas_stringshare_del(epr->source); TODO FIXME
+   _edje_if_string_free(ed, epr->source);
    epr->source = evas_stringshare_add(source);
    
    //Update patterns
@@ -2840,7 +2846,7 @@
    
    printf("SET SIGNAL for program: %s [%s]\n", prog, signal);
    
-   //if (epr->signal && ed->file->free_strings) 
evas_stringshare_del(epr->signal); TODO FIXME
+   _edje_if_string_free(ed, epr->signal);
    epr->signal = evas_stringshare_add(signal);
    
    //Update patterns
@@ -2869,7 +2875,7 @@
    
    printf("SET STATE for program: %s\n", prog);
    
-   //if (epr->state && ed->file->free_strings) 
evas_stringshare_del(epr->state); TODO FIXME
+   _edje_if_string_free(ed, epr->state);
    epr->state = evas_stringshare_add(state);
    
    return 1;
@@ -2893,7 +2899,7 @@
    
    printf("SET STATE2 for program: %s\n", prog);
    
-   //if (epr->state2 && ed->file->free_strings) 
evas_stringshare_del(epr->state2); TODO FIXME
+   _edje_if_string_free(ed, epr->state2);
    epr->state2 = evas_stringshare_add(state2);
    
    return 1;



-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to