edje_edit: save referenced groups when image id's are changed
authorVitalii Vorobiov <vi.vorobiov@samsung.com>
Wed, 15 Jun 2016 09:53:15 +0000 (12:53 +0300)
committerVitalii Vorobiov <vi.vorobiov@samsung.com>
Wed, 15 Jun 2016 10:35:04 +0000 (13:35 +0300)
@fix

src/lib/edje/edje_edit.c

index 134a15c..c10d1eb 100644 (file)
@@ -9217,6 +9217,7 @@ edje_edit_image_set_del(Evas_Object *obj, const char *name)
 {
    Edje_Image_Directory_Set *de = NULL, *de_last = NULL;
    Edje_Image_Directory_Set_Entry *dim = NULL;
+   Eet_File *eetf;
    unsigned int i, j, k;
    Eina_List *used;
    Eina_Iterator *it;
@@ -9252,6 +9253,14 @@ edje_edit_image_set_del(Evas_Object *obj, const char *name)
 
    --ed->file->image_dir->sets_count;
 
+   /* open the eet file */
+   eetf = eet_open(ed->path, EET_FILE_MODE_READ_WRITE);
+   if (!eetf)
+     {
+        ERR("Unable to open \"%s\" for writing output", ed->path);
+        return EINA_FALSE;
+     }
+
    if (de_last->id != de->id)
      {
         Edje_Part *part;
@@ -9286,6 +9295,11 @@ edje_edit_image_set_del(Evas_Object *obj, const char *name)
                          }
                     }
                }
+             if (!_edje_edit_collection_save(eetf, pce->ref))
+               {
+                  eet_close(eetf);
+                  return EINA_FALSE;
+               }
           }
         eina_iterator_free(it);
      }
@@ -9293,6 +9307,8 @@ edje_edit_image_set_del(Evas_Object *obj, const char *name)
                                           sizeof(Edje_Image_Directory_Set_Entry) *
                                           ed->file->image_dir->sets_count);
 
+   eet_close(eetf);
+
    return EINA_TRUE;
 }
 
@@ -9651,6 +9667,7 @@ edje_edit_image_replace(Evas_Object *obj, const char *name, const char *new_name
    Eina_Iterator *it;
    Edje_Part_Collection_Directory_Entry *pce;
    Edje_Part *part;
+   Eet_File *eetf;
    Edje_Part_Description_Image *part_desc_image;
    unsigned int i, j, k;
    int image_id, new_image_id;
@@ -9664,6 +9681,14 @@ edje_edit_image_replace(Evas_Object *obj, const char *name, const char *new_name
 
    it = eina_hash_iterator_data_new(ed->file->collection);
 
+   /* open the eet file */
+   eetf = eet_open(ed->path, EET_FILE_MODE_READ_WRITE);
+   if (!eetf)
+     {
+        ERR("Unable to open \"%s\" for writing output", ed->path);
+        return EINA_FALSE;
+     }
+
    EINA_ITERATOR_FOREACH(it, pce)
      {
         for (i = 0; i < pce->ref->parts_count; i++)
@@ -9687,10 +9712,17 @@ edje_edit_image_replace(Evas_Object *obj, const char *name, const char *new_name
                            part_desc_image->image.id = new_image_id;
                     }
                }
+             if (!_edje_edit_collection_save(eetf, pce->ref))
+               {
+                  eet_close(eetf);
+                  return EINA_FALSE;
+               }
           }
      }
    eina_iterator_free(it);
 
+   eet_close(eetf);
+
    return EINA_TRUE;
 }
 
@@ -9946,6 +9978,11 @@ edje_edit_image_del(Evas_Object *obj, const char *name)
                             }
                        }
                   }
+                if (!_edje_edit_collection_save(eetf, pce->ref))
+                  {
+                     eet_close(eetf);
+                     return EINA_FALSE;
+                  }
              }
            eina_iterator_free(it);
         }