backport textblock leak.
authorraster <raster@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Wed, 21 Nov 2012 09:12:59 +0000 (09:12 +0000)
committerraster <raster@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Wed, 21 Nov 2012 09:12:59 +0000 (09:12 +0000)
git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/branches/evas-1.7@79504 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

ChangeLog
NEWS
src/lib/canvas/evas_object_textgrid.c
src/lib/engines/common/evas_text_utils.c
src/lib/engines/common/evas_text_utils.h

index 239d05b..2010e8a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
 
         * Fix the evas memory leak - eina_rectangles allocated internally.
 
+2012-11-21  Carsten Haitzler (The Rasterman)
+
+        * Fixed leak in textblock and text props in general that made
+        textblock recalcs lead very badly. Required changed to textgrid
+        though a sit relied on the leaky behavior.
+        
diff --git a/NEWS b/NEWS
index b577b1c..94258aa 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -7,7 +7,8 @@ Fixes:
    * Fix evas textblock tag parser to respect escaped spaces and escaped single quotes
    * Fixed longstanding memset bug in evas box.
    * Fixed GLX native surface handling (fixes new mesa+intel comp bug).
-
+   * Fixed textblock textprop leak.
+    
 Changes since Evas 1.7.0:
 -------------------------
 
index f047518..4e12b25 100644 (file)
@@ -194,7 +194,7 @@ evas_object_textgrid_textprop_ref(Evas_Object *obj, Evas_Object_Textgrid *o, Ein
 
    if (o->last_glyphs)
      {
-        if (o->last_mask && (o->last_mask & codepoint) == o->last_mask)
+        if ((o->last_mask) && ((o->last_mask & codepoint) == o->last_mask))
           goto end;
      }
 
@@ -235,8 +235,8 @@ evas_object_textgrid_textprop_ref(Evas_Object *obj, Evas_Object_Textgrid *o, Ein
         goto end;
      }
 
-   while (shift > 8
-          && o->master[offset].next[(codepoint & mask) >> shift] != 0)
+   while ((shift > 8)
+          && (o->master[offset].next[(codepoint & mask) >> shift] != 0))
      {
         offset = o->master[offset].next[(codepoint & mask) >> shift];
         mask >>= 4;
@@ -322,7 +322,12 @@ evas_object_textgrid_textprop_unref(Evas_Object_Textgrid *o, unsigned int props_
           eina_array_push(&o->glyphs_cleanup,
                           (void *)((unsigned long)props_index));
         else
-          evas_common_text_props_content_unref(props);
+          {
+             Evas_Glyph *glyphs = props->glyphs;
+             int glyphs_length = props->glyphs_length;
+
+             evas_common_text_props_content_nofree_unref(props);
+          }
      }
 }
 
@@ -456,8 +461,8 @@ evas_object_textgrid_free(Evas_Object *obj)
 
         props_index = (unsigned int) (intptr_t) eina_array_pop(&o->glyphs_cleanup);
         prop = &(o->glyphs[props_index >> 8].props[props_index & 0xFF]);
-        
-        evas_common_text_props_content_unref(prop);
+
+        evas_common_text_props_content_nofree_unref(prop);
         if (!prop->info)
           {
              o->glyphs_used[props_index >> 8]--;
@@ -853,7 +858,7 @@ evas_object_textgrid_render_post(Evas_Object *obj)
         props_index = (unsigned int) (intptr_t) eina_array_pop(&o->glyphs_cleanup);
         prop = &(o->glyphs[props_index >> 8].props[props_index & 0xFF]);
         
-        evas_common_text_props_content_unref(prop);
+        evas_common_text_props_content_nofree_unref(prop);
         if (!prop->info)
           {
              o->glyphs_used[props_index >> 8]--;
@@ -1186,7 +1191,7 @@ evas_object_textgrid_font_set(Evas_Object *obj, const char *font_name, Evas_Font
         props_index = (unsigned int) (intptr_t) eina_array_pop(&o->glyphs_cleanup);
         prop = &(o->glyphs[props_index >> 8].props[props_index & 0xFF]);
         
-        evas_common_text_props_content_unref(prop);
+        evas_common_text_props_content_nofree_unref(prop);
         if (!prop->info)
           {
              o->glyphs_used[props_index >> 8]--;
index acdcc00..7abf07f 100644 (file)
@@ -54,7 +54,7 @@ evas_common_text_props_content_ref(Evas_Text_Props *props)
 }
 
 void
-evas_common_text_props_content_unref(Evas_Text_Props *props)
+evas_common_text_props_content_nofree_unref(Evas_Text_Props *props)
 {
    /* No content in this case */
    if (!props->info)
@@ -65,13 +65,43 @@ evas_common_text_props_content_unref(Evas_Text_Props *props)
         evas_common_font_int_unref(props->font_instance);
         props->font_instance = NULL;
      }
-   
+
    if (--(props->info->refcount) == 0)
      {
         free(props->glyphs);
         props->glyphs = NULL;
         props->glyphs_length = 0;
+        
+        if (props->info->glyph)
+          free(props->info->glyph);
+#ifdef OT_SUPPORT
+        if (props->info->ot)
+          free(props->info->ot);
+#endif
+        free(props->info);
+        props->info = NULL;
+     }
+}
 
+void
+evas_common_text_props_content_unref(Evas_Text_Props *props)
+{
+   /* No content in this case */
+   if (!props->info)
+      return;
+
+   if (props->font_instance)
+     {
+        evas_common_font_int_unref(props->font_instance);
+        props->font_instance = NULL;
+     }
+   
+   free(props->glyphs);
+   props->glyphs = NULL;
+   props->glyphs_length = 0;
+
+   if (--(props->info->refcount) == 0)
+     {
         if (props->info->glyph)
           free(props->info->glyph);
 #ifdef OT_SUPPORT
index 675df6c..2b1caf1 100644 (file)
@@ -81,6 +81,9 @@ void
 evas_common_text_props_content_ref(Evas_Text_Props *props);
 
 void
+evas_common_text_props_content_nofree_unref(Evas_Text_Props *props);
+
+void
 evas_common_text_props_content_unref(Evas_Text_Props *props);
 
 EAPI int