Evas text_utils: make the text_props_content_ref/unref more robust.
authortasn <tasn@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Thu, 10 Feb 2011 15:29:13 +0000 (15:29 +0000)
committertasn <tasn@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Thu, 10 Feb 2011 15:29:13 +0000 (15:29 +0000)
Don't allocate a text info if the length is 0. No point in that because
content won't be allocated anyway.

git-svn-id: http://svn.enlightenment.org/svn/e/trunk/evas@56924 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

src/lib/engines/common/evas_text_utils.c

index 954000d..b94e6ff 100644 (file)
@@ -39,8 +39,8 @@ evas_common_text_props_content_copy_and_ref(Evas_Text_Props *dst,
 void
 evas_common_text_props_content_ref(Evas_Text_Props *props)
 {
-   /* No info in this case */
-   if (props->len == 0)
+   /* No content in this case */
+   if (!props->info)
       return;
 
    props->info->refcount++;
@@ -49,8 +49,8 @@ evas_common_text_props_content_ref(Evas_Text_Props *props)
 void
 evas_common_text_props_content_unref(Evas_Text_Props *props)
 {
-   /* No info in this case */
-   if (props->len == 0)
+   /* No content in this case */
+   if (!props->info)
       return;
 
    if (--(props->info->refcount) == 0)
@@ -175,6 +175,11 @@ evas_common_text_props_content_create(void *_fn, const Eina_Unicode *text,
      {
         evas_common_text_props_content_unref(text_props);
      }
+   if (len == 0)
+     {
+        text_props->info = NULL;
+        text_props->start = text_props->len = text_props->text_offset = 0;
+     }
    text_props->info = calloc(1, sizeof(Evas_Text_Props_Info));
 
    fi = fn->fonts->data;