Don't free file entries while there are still images pending from them
authorsachiel <sachiel@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Mon, 25 Jun 2012 19:27:59 +0000 (19:27 +0000)
committersachiel <sachiel@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Mon, 25 Jun 2012 19:27:59 +0000 (19:27 +0000)
git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/evas@72826 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

src/bin/evas_cserve2_cache.c

index dcf43d8..bdc20a3 100644 (file)
@@ -596,7 +596,11 @@ _image_entry_free(Image_Data *entry)
      }
 
    if (fentry)
-     fentry->images = eina_list_remove(fentry->images, entry);
+     {
+        fentry->images = eina_list_remove(fentry->images, entry);
+        if (!fentry->images && !fentry->base.references)
+          eina_hash_del_by_key(file_entries, &fentry->base.id);
+     }
    if (entry->shm)
      cserve2_shm_unref(entry->shm);
    free(entry);
@@ -1069,13 +1073,10 @@ _entry_reference_del(Entry *entry, Reference *ref)
 
         if (fentry->invalid)
           _file_entry_free(fentry);
-        else
-          {
-             Image_Data *ie;
-             EINA_LIST_FREE(fentry->images, ie)
-                ie->file = NULL;
-             eina_hash_del_by_key(file_entries, &entry->id);
-          }
+        else if (!fentry->images)
+          eina_hash_del_by_key(file_entries, &entry->id);
+        /* don't free file entries that have images attached to it, they will
+         * be freed when the last unused image is freed */
      }
    else if (entry->type == CSERVE2_IMAGE_DATA)
      {