Enlightenment CVS committal

Author  : moom16
Project : e17
Module  : proto

Dir     : e17/proto/etk/src/lib


Modified Files:
        etk_image.c etk_image.h 


Log Message:
* Fix a too high memory consumption of etk_image when you change the image often


===================================================================
RCS file: /cvsroot/enlightenment/e17/proto/etk/src/lib/etk_image.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -3 -r1.6 -r1.7
--- etk_image.c 29 Oct 2005 19:57:20 -0000      1.6
+++ etk_image.c 30 Oct 2005 13:38:54 -0000      1.7
@@ -129,6 +129,7 @@
    if (image->use_edje)
    {
       image->use_edje = FALSE;
+      image->object_type_changed = TRUE;
       etk_object_notify(ETK_OBJECT(image), "use_edje");
    }
 
@@ -142,7 +143,7 @@
  */
 const char *etk_image_file_get(Etk_Image *image)
 {
-   if (!image)
+   if (!image || image->use_edje)
       return NULL;
    return image->filename;
 }
@@ -187,6 +188,7 @@
    if (!image->use_edje)
    {
       image->use_edje = TRUE;
+      image->object_type_changed = TRUE;
       etk_object_notify(ETK_OBJECT(image), "use_edje");
    }
 
@@ -201,7 +203,7 @@
  */
 void etk_image_edje_file_get(Etk_Image *image, char **edje_filename, char 
**edje_group)
 {
-   if (!image)
+   if (!image || !image->use_edje)
    {
       if (edje_filename)
          *edje_filename = NULL;
@@ -264,6 +266,7 @@
    image->edje_group = NULL;
    image->keep_aspect = TRUE;
    image->use_edje = FALSE;
+   image->object_type_changed = FALSE;
 
    widget->size_request = _etk_image_size_request;
    widget->move_resize = _etk_image_move_resize;
@@ -442,32 +445,33 @@
    if (!(widget = ETK_WIDGET(image)))
       return;
 
-   if (image->image_object)
+   if (image->image_object && image->object_type_changed)
    {
       etk_widget_member_object_del(widget, image->image_object);
       evas_object_del(image->image_object);
       image->image_object = NULL;
+      image->object_type_changed = FALSE;
    }
    if (image->filename)
    {
       int error_code;
       Evas *evas;
 
-      if ((evas = etk_widget_toplevel_evas_get(widget)))
+      if (!image->image_object && (evas = 
etk_widget_toplevel_evas_get(widget)))
       {
          image->image_object = evas_object_image_add(evas);
+         etk_widget_member_object_add(widget, image->image_object);
+      }
+      if (image->image_object)
+      {
          evas_object_image_file_set(image->image_object, image->filename, 
NULL);
          if ((error_code = 
evas_object_image_load_error_get(image->image_object)))
          {
             ETK_WARNING("Unable to load image from file \"%s\", error %d", 
image->filename, error_code);
-            evas_object_del(image->image_object);
-            image->image_object = NULL;
+            evas_object_hide(image->image_object);
          }
          else
-         {
             evas_object_show(image->image_object);
-            etk_widget_member_object_add(widget, image->image_object);
-         }
       }
    }
    else if (image->edje_filename && image->edje_group)
@@ -475,18 +479,21 @@
       int error_code;
       Evas *evas;
 
-      if ((evas = etk_widget_toplevel_evas_get(widget)))
+      if (!image->image_object && (evas = 
etk_widget_toplevel_evas_get(widget)))
       {
          image->image_object = edje_object_add(evas);
+         etk_widget_member_object_add(widget, image->image_object);
+      }
+      if (image->image_object)
+      {
          edje_object_file_set(image->image_object, image->edje_filename, 
image->edje_group);
          if ((error_code = edje_object_load_error_get(image->image_object)))
          {
             ETK_WARNING("Unable to load image from edje file \"%s\"/\"%s\", 
error %d", image->edje_filename, image->edje_group, error_code);
-            evas_object_del(image->image_object);
-            image->image_object = NULL;
+            evas_object_hide(image->image_object);
          }
          else
-            etk_widget_member_object_add(widget, image->image_object);
+            evas_object_show(image->image_object);
       }
    }
 
===================================================================
RCS file: /cvsroot/enlightenment/e17/proto/etk/src/lib/etk_image.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -3 -r1.2 -r1.3
--- etk_image.h 2 Oct 2005 15:40:28 -0000       1.2
+++ etk_image.h 30 Oct 2005 13:38:54 -0000      1.3
@@ -33,6 +33,7 @@
    char *edje_filename;
    Etk_Bool keep_aspect;
    Etk_Bool use_edje;
+   Etk_Bool object_type_changed;
 };
 
 Etk_Type *etk_image_type_get();




-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc.
Get Certified Today * Register for a JBoss Training Course
Free Certification Exam for All Training Attendees Through End of 2005
Visit http://www.jboss.com/services/certification for more information
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to