summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrii Kroitor <an.kroitor@samsung.com>2014-04-17 19:40:34 +0200
committerCedric Bail <cedric.bail@free.fr>2014-04-17 19:40:36 +0200
commitc17d08d2ab52c12583570c47a29ae65ee72409c7 (patch)
treec96db96f05522c1567cb4f7c3eb72f77a344af3b
parent80b1ca8e4373534ad9ac848cdb7f34862cfee017 (diff)
edje_edit: image_del fixed
Summary: fixed segfault on broken refs in edje object Reviewers: cedric, seoz, raster CC: reutskiy.v.v, cedric Differential Revision: https://phab.enlightenment.org/D759 Signed-off-by: Cedric Bail <cedric.bail@free.fr>
-rw-r--r--src/lib/edje/edje_edit.c89
1 files changed, 46 insertions, 43 deletions
diff --git a/src/lib/edje/edje_edit.c b/src/lib/edje/edje_edit.c
index 6120ff0..8c67e0a 100644
--- a/src/lib/edje/edje_edit.c
+++ b/src/lib/edje/edje_edit.c
@@ -5069,8 +5069,10 @@ edje_edit_image_usage_list_get(Evas_Object *obj, const char *name, Eina_Bool fir
5069 5069
5070 EINA_ITERATOR_FOREACH(it, pce) 5070 EINA_ITERATOR_FOREACH(it, pce)
5071 { 5071 {
5072 if (!pce->ref) continue;
5072 for (i = 0; i < pce->ref->parts_count; i++) 5073 for (i = 0; i < pce->ref->parts_count; i++)
5073 { 5074 {
5075 if (!pce->ref->parts) continue;
5074 part = pce->ref->parts[i]; 5076 part = pce->ref->parts[i];
5075 if (part->type == EDJE_PART_TYPE_IMAGE) 5077 if (part->type == EDJE_PART_TYPE_IMAGE)
5076 { 5078 {
@@ -5175,6 +5177,50 @@ edje_edit_image_del(Evas_Object *obj, const char* name)
5175 eet_delete(eetf, last_entry); 5177 eet_delete(eetf, last_entry);
5176 eet_write(eetf, entry, data, size, 0); 5178 eet_write(eetf, entry, data, size, 0);
5177 } 5179 }
5180
5181 _edje_if_string_free(ed, de->entry);
5182 --ed->file->image_dir->entries_count;
5183
5184 if (de_last->id != de->id)
5185 {
5186 Edje_Part *part;
5187 Edje_Part_Description_Image *part_desc_image;
5188
5189 de->entry = de_last->entry;
5190 it = eina_hash_iterator_data_new(ed->file->collection);
5191 EINA_ITERATOR_FOREACH(it, pce)
5192 {
5193 if (!pce->ref) continue;
5194 for (i = 0; i < pce->ref->parts_count; i++)
5195 {
5196 if (!pce->ref->parts) continue;
5197 part = pce->ref->parts[i];
5198 if (part->type == EDJE_PART_TYPE_IMAGE)
5199 {
5200 part_desc_image = (Edje_Part_Description_Image *)part->default_desc;
5201 if (part_desc_image->image.id == de_last->id)
5202 part_desc_image->image.id = de->id;
5203 for (k = 0; k < part_desc_image->image.tweens_count; k++)
5204 if (part_desc_image->image.id == de_last->id)
5205 part_desc_image->image.id = de->id;
5206
5207 for (j = 0; j < part->other.desc_count; j++)
5208 {
5209 part_desc_image = (Edje_Part_Description_Image *)part->other.desc[j];
5210 if (part_desc_image->image.id == de_last->id)
5211 part_desc_image->image.id = de->id;
5212 for (k = 0; k < part_desc_image->image.tweens_count; k++)
5213 if (part_desc_image->image.id == de_last->id)
5214 part_desc_image->image.id = de->id;
5215 }
5216 }
5217 }
5218 }
5219 eina_iterator_free(it);
5220 }
5221 ed->file->image_dir->entries = realloc(ed->file->image_dir->entries,
5222 sizeof(Edje_Image_Directory_Entry) *
5223 ed->file->image_dir->entries_count);
5178 /* write the edje_file */ 5224 /* write the edje_file */
5179 if (!_edje_edit_edje_file_save(eetf, ed->file)) 5225 if (!_edje_edit_edje_file_save(eetf, ed->file))
5180 { 5226 {
@@ -5184,49 +5230,6 @@ edje_edit_image_del(Evas_Object *obj, const char* name)
5184 5230
5185 eet_close(eetf); 5231 eet_close(eetf);
5186 } 5232 }
5187
5188
5189 _edje_if_string_free(ed, de->entry);
5190 --ed->file->image_dir->entries_count;
5191
5192 if (de_last->id != de->id)
5193 {
5194 Edje_Part *part;
5195 Edje_Part_Description_Image *part_desc_image;
5196
5197 de->entry = de_last->entry;
5198 it = eina_hash_iterator_data_new(ed->file->collection);
5199 EINA_ITERATOR_FOREACH(it, pce)
5200 {
5201 for (i = 0; i < pce->ref->parts_count; i++)
5202 {
5203 part = pce->ref->parts[i];
5204 if (part->type == EDJE_PART_TYPE_IMAGE)
5205 {
5206 part_desc_image = (Edje_Part_Description_Image *)part->default_desc;
5207 if (part_desc_image->image.id == de_last->id)
5208 part_desc_image->image.id = de->id;
5209 for (k = 0; k < part_desc_image->image.tweens_count; k++)
5210 if (part_desc_image->image.id == de_last->id)
5211 part_desc_image->image.id = de->id;
5212
5213 for (j = 0; j < part->other.desc_count; j++)
5214 {
5215 part_desc_image = (Edje_Part_Description_Image *)part->other.desc[j];
5216 if (part_desc_image->image.id == de_last->id)
5217 part_desc_image->image.id = de->id;
5218 for (k = 0; k < part_desc_image->image.tweens_count; k++)
5219 if (part_desc_image->image.id == de_last->id)
5220 part_desc_image->image.id = de->id;
5221 }
5222 }
5223 }
5224 }
5225 eina_iterator_free(it);
5226 }
5227 ed->file->image_dir->entries = realloc(ed->file->image_dir->entries,
5228 sizeof(Edje_Image_Directory_Entry) *
5229 ed->file->image_dir->entries_count);
5230 _edje_edit_flag_script_dirty(eed, EINA_TRUE); 5233 _edje_edit_flag_script_dirty(eed, EINA_TRUE);
5231 5234
5232 return EINA_TRUE; 5235 return EINA_TRUE;