}
static void
-_edje_if_string_free(Edje *ed, const char *str)
+_edje_if_string_free(Edje *ed, const char **str)
{
Eet_Dictionary *dict;
if (!ed || !str) return;
dict = eet_dictionary_get(ed->file->ef);
- if (eet_dictionary_string_check(dict, str)) return;
- eina_stringshare_del(str);
- str = NULL;
+ if (eet_dictionary_string_check(dict, *str)) return;
+ eina_stringshare_del(*str);
+ *str = NULL;
+}
+
+static void
+_edje_if_string_replace(Edje *ed, const char **str, const char *str_new)
+{
+ Eet_Dictionary *dict;
+
+ if (!ed || !str) return;
+
+ dict = eet_dictionary_get(ed->file->ef);
+ if (*str && eet_dictionary_string_check(dict, *str))
+ *str = eina_stringshare_add(str_new);
+ else
+ eina_stringshare_replace(str, str_new);
}
static Edje_Style *
{
program->speed = 0;
program->channel = EDJE_CHANNEL_EFFECT;
- _edje_if_string_free(eed, program->sample_name);
- program->sample_name = NULL;
+ _edje_if_string_free(eed, &program->sample_name);
program->action = EDJE_ACTION_TYPE_NONE;
is_collection_changed = EINA_TRUE;
}
!strcmp(program->tone_name, name))
{
program->duration = 0;
- _edje_if_string_free(eed, program->tone_name);
- program->tone_name = NULL;
+ _edje_if_string_free(eed, &program->tone_name);
program->action = EDJE_ACTION_TYPE_NONE;
is_collection_changed = EINA_TRUE;
}
return EINA_FALSE;
}
- _edje_if_string_free(ed, sound_sample->name);
+ _edje_if_string_free(ed, &sound_sample->name);
--ed->file->sound_dir->samples_count;
sound_sample_last = ed->file->sound_dir->samples +
return EINA_FALSE;
}
-
- _edje_if_string_free(ed, sound_tone->name);
+ _edje_if_string_free(ed, &sound_tone->name);
--ed->file->sound_dir->tones_count;
Edje_Sound_Tone *sound_tone_last = ed->file->sound_dir->tones +
if ((ed->collection->limits.TYPE[i]->value == value) \
&& (!strcmp(ed->collection->limits.TYPE[i]->name, name))) \
{ \
- _edje_if_string_free(ed, ed->collection->limits.TYPE[i]->name); \
+ _edje_if_string_free(ed, &ed->collection->limits.TYPE[i]->name); \
free(ed->collection->limits.TYPE[i]); \
if (i < new_count) \
{ \
if (!value) return EINA_FALSE;
eina_hash_del(ed->collection->data, key, value);
- _edje_if_string_free(ed, value->str);
+ _edje_if_string_free(ed, &value->str);
free(value);
return EINA_TRUE;
return EINA_FALSE;
eina_hash_del(ed->file->data, itemname, value);
- _edje_if_string_free(ed, value->str);
+ _edje_if_string_free(ed, &value->str);
free(value);
return EINA_TRUE;
es = eina_hash_find(ed->collection->data, key);
if (es)
{
- _edje_if_string_free(ed, es->str);
- es->str = eina_stringshare_add(value);
+ _edje_if_string_replace(ed, &es->str, value);
es->id = 0;
- return EINA_TRUE;
+ return EINA_TRUE;
}
return EINA_FALSE;
es = eina_hash_find(ed->file->data, itemname);
if (es)
{
- _edje_if_string_free(ed, es->str);
- es->str = eina_stringshare_add(value);
+ _edje_if_string_replace(ed, &es->str, value);
es->id = 0;
return EINA_TRUE;
}
EINA_LIST_FOREACH(ed->file->color_classes, l, cc)
if (strcmp(cc->name, name) == 0)
{
- _edje_if_string_free(ed, cc->name);
+ _edje_if_string_free(ed, &cc->name);
ed->file->color_classes = eina_list_remove(ed->file->color_classes, cc);
free(cc);
return EINA_TRUE;
EINA_LIST_FOREACH(ed->file->color_classes, l, cc)
if (!strcmp(cc->name, name))
{
- _edje_if_string_free(ed, cc->name);
- cc->name = (char*)eina_stringshare_add(newname);
- return EINA_TRUE;
+ _edje_if_string_replace(ed, &cc->name, newname);
+ return EINA_TRUE;
}
return EINA_FALSE;
ed->file->styles = eina_list_remove(ed->file->styles, s);
- _edje_if_string_free(ed, s->name);
+ _edje_if_string_free(ed, (const char **)&s->name);
//~ //s->style HOWTO FREE ???
while (s->tags)
{
t = s->tags->data;
s->tags = eina_list_remove(s->tags, t);
- _edje_if_string_free(ed, t->key);
- _edje_if_string_free(ed, t->value);
- _edje_if_string_free(ed, t->font);
- _edje_if_string_free(ed, t->text_class);
+ _edje_if_string_free(ed, &t->key);
+ _edje_if_string_free(ed, &t->value);
+ _edje_if_string_free(ed, &t->font);
+ _edje_if_string_free(ed, &t->text_class);
free(t);
t = NULL;
}
t = _edje_edit_style_tag_get(ed, style, tag);
if (!t) return EINA_FALSE;
- _edje_if_string_free(ed, t->key);
- t->key = eina_stringshare_add(new_name);
+ _edje_if_string_replace(ed, &t->key, new_name);
return EINA_TRUE;
}
t = _edje_edit_style_tag_get(ed, style, tag);
if (!t) return EINA_FALSE;
- _edje_if_string_free(ed, t->value);
- t->value = eina_stringshare_add(new_value);
+ _edje_if_string_replace(ed, &t->value, new_value);
return EINA_TRUE;
}
if (!s || !t) return EINA_FALSE;
s->tags = eina_list_remove(s->tags, t);
- _edje_if_string_free(ed, t->key);
- _edje_if_string_free(ed, t->value);
- _edje_if_string_free(ed, t->font);
- _edje_if_string_free(ed, t->text_class);
+ _edje_if_string_free(ed, &t->key);
+ _edje_if_string_free(ed, &t->value);
+ _edje_if_string_free(ed, &t->font);
+ _edje_if_string_free(ed, &t->text_class);
free(t);
t = NULL;
return EINA_TRUE;
e = _edje_edit_external_get(ed, external);
if (!e) return EINA_FALSE;
- _edje_if_string_free(ed, e->entry);
+ _edje_if_string_free(ed, &e->entry);
e->entry = NULL;
return EINA_TRUE;
//printf("Set name of part: %s [new name: %s]\n", part, new_name);
- _edje_if_string_free(ed, rp->part->name);
- rp->part->name = (char *)eina_stringshare_add(new_name);
+ _edje_if_string_replace(ed, &rp->part->name, new_name);
_edje_edit_flag_script_dirty(eed, EINA_TRUE);
edje_edit_part_api_##Value##_set(Evas_Object *obj, const char *part, const char *s) \
{ \
GET_RP_OR_RETURN(EINA_FALSE); \
- _edje_if_string_free(ed, rp->part->api.Value); \
- rp->part->api.Value = eina_stringshare_add(s); \
+ _edje_if_string_replace(ed, &rp->part->api.Value, s); \
return EINA_TRUE; \
}
/* Create default description */
if (!edje_edit_state_add(obj, name, "default", 0.0))
{
- _edje_if_string_free(ed, ep->name);
+ _edje_if_string_free(ed, &ep->name);
if (source)
- _edje_if_string_free(ed, ep->source);
+ _edje_if_string_free(ed, &ep->source);
eina_mempool_free(ce->mp.part, ep);
eina_mempool_free(_edje_real_part_mp, rp);
return EINA_FALSE;
/* Free Edje_Part and all descriptions */
ce = eina_hash_find(ed->file->collection, ed->group);
- _edje_if_string_free(ed, ep->name);
+ _edje_if_string_free(ed, &ep->name);
if (ep->default_desc)
{
_edje_collection_free_part_description_free(ep->type, ep->default_desc, ce, 0);
}
// this fall through case is intentional
case EDJE_PART_TYPE_TEXTBLOCK:
- _edje_if_string_free(ed, rp->part->source);
- if (source) rp->part->source = eina_stringshare_add(source);
- else rp->part->source = NULL;
+ if (source) _edje_if_string_replace(ed, &rp->part->source, source);
+ else _edje_if_string_free(ed, &rp->part->source);
return EINA_TRUE;
case EDJE_PART_TYPE_EXTERNAL: //EXTERNAL part has source property but it cannot be changed
break;
{
Edje_Pack_Element **tmp;
- _edje_if_string_free(ed, item->name);
+ _edje_if_string_free(ed, &item->name);
--ep->items_count;
while (i < ep->items_count)
!strcmp(epr->state, pd->state.name) &&
pd->state.value == epr->value)
{
- _edje_if_string_free(ed, epr->state);
- epr->state = eina_stringshare_add(new_name);
+ _edje_if_string_replace(ed, &epr->state, new_name);
epr->value = value;
}
}
}
/* set name */
- _edje_if_string_free(ed, pd->state.name);
- pd->state.name = (char *)eina_stringshare_add(new_name);
+ _edje_if_string_replace(ed, &pd->state.name, new_name);
/* set value */
pd->state.value = new_value;
rpto->part->other.desc[rpto->part->other.desc_count++] = pdto;
}
+
#define PD_STRING_COPY(To, From, _x) \
- _edje_if_string_free(ed, To->_x); \
- To->_x = (char *)eina_stringshare_add(From->_x);
+ if (From->_x) \
+ To->_x = (char *)eina_stringshare_add(From->_x);
/* Copy all value */
*pdto = *pdfrom;
/* XXX: optimize this, most likely we don't need to remove and add */
EINA_LIST_FREE(ext_to->external_params, p)
{
- _edje_if_string_free(ed, p->name);
+ _edje_if_string_free(ed, &p->name);
if (p->s)
- _edje_if_string_free(ed, p->s);
+ _edje_if_string_free(ed, &p->s);
free(p);
}
EINA_LIST_FOREACH(ext_from->external_params, l, p)
p->type = type;
p->i = 0;
p->d = 0;
- _edje_if_string_free(ed, p->s);
- p->s = NULL;
+ _edje_if_string_free(ed, &p->s);
switch (type)
{
if ((type == EDJE_EXTERNAL_PARAM_TYPE_CHOICE) ||
(type == EDJE_EXTERNAL_PARAM_TYPE_STRING))
{
- _edje_if_string_free(ed, p->s);
+ _edje_if_string_free(ed, &p->s);
if (!found) free(p);
else *p = old_p;
eina_stringshare_del(sname);
txt = (Edje_Part_Description_Text *) pd;
- _edje_if_string_free(ed, txt->text.text.str);
- txt->text.text.str = (char *)eina_stringshare_add(text);
+ _edje_if_string_replace(ed, &txt->text.text.str, text);
txt->text.text.id = 0;
for (i = 0; i < ed->table_parts_size; i++)
(real->typedata.text) && (real->typedata.text->text_source == rp))
{
txt = _edje_real_part_text_text_source_description_get(real, NULL);
- _edje_if_string_free(ed, txt->text.text.str);
- txt->text.text.str = (char *)eina_stringshare_add(text);
+ _edje_if_string_replace(ed, &txt->text.text.str, text);
txt->text.text.id = 0;
}
}
txt = (Edje_Part_Description_Text*) pd;
- _edje_if_string_free(ed, txt->text.font.str);
- txt->text.font.str = (char *)eina_stringshare_add(font);
+ _edje_if_string_replace(ed, &txt->text.font.str, font);
txt->text.font.id = 0;
edje_object_calc_force(obj);
txt->text.id_text_source = id_text_source;
text_source = source_txt->text.text.str;
- _edje_if_string_free(ed, txt->text.text.str);
- txt->text.text.str = eina_stringshare_add(text_source);
+ _edje_if_string_replace(ed, &txt->text.text.str, text_source);
txt->text.text.id = 0;
}
else
return EINA_FALSE;
txt = (Edje_Part_Description_Text*) pd;
- _edje_if_string_free(ed, txt->text.repch.str);
- txt->text.repch.str = eina_stringshare_add(repch);
+ _edje_if_string_replace(ed, &txt->text.repch.str, repch);
txt->text.repch.id = 0;
edje_object_calc_force(obj);
eet_write(eetf, entry, data, size, 0);
}
- _edje_if_string_free(ed, de->entry);
+ _edje_if_string_free(ed, &de->entry);
--ed->file->image_dir->entries_count;
if (de_last->id != de->id)
if ((unsigned int) id >= ed->file->image_dir->entries_count) return EINA_FALSE;
de = ed->file->image_dir->entries + id;
- _edje_if_string_free(ed, de->entry);
- de->entry = eina_stringshare_add(name);
+ _edje_if_string_replace(ed, &de->entry, name);
de->source_type = 1;
de->source_param = 1;
}
//Free Edje_Program
- _edje_if_string_free(ed, epr->name);
- _edje_if_string_free(ed, epr->signal);
- _edje_if_string_free(ed, epr->source);
- _edje_if_string_free(ed, epr->filter.part);
- _edje_if_string_free(ed, epr->filter.state);
- _edje_if_string_free(ed, epr->state);
- _edje_if_string_free(ed, epr->state2);
- _edje_if_string_free(ed, epr->sample_name);
- _edje_if_string_free(ed, epr->tone_name);
+ _edje_if_string_free(ed, &epr->name);
+ _edje_if_string_free(ed, &epr->signal);
+ _edje_if_string_free(ed, &epr->source);
+ _edje_if_string_free(ed, &epr->filter.part);
+ _edje_if_string_free(ed, &epr->filter.state);
+ _edje_if_string_free(ed, &epr->state);
+ _edje_if_string_free(ed, &epr->state2);
+ _edje_if_string_free(ed, &epr->sample_name);
+ _edje_if_string_free(ed, &epr->tone_name);
EINA_LIST_FREE(epr->targets, prt)
free(prt);
//printf("SET NAME for program: %s [new name: %s]\n", prog, new_name);
- _edje_if_string_free(ed, epr->name);
- epr->name = eina_stringshare_add(new_name);
+ _edje_if_string_replace(ed, &epr->name, new_name);
_edje_edit_flag_script_dirty(eed, EINA_TRUE);
/* Remove from program array */
_edje_program_remove(ed->collection, epr);
- _edje_if_string_free(ed, epr->source);
/* Insert it back */
- epr->source = eina_stringshare_add(source);
+ _edje_if_string_replace(ed, &epr->source, source);
_edje_program_insert(ed->collection, epr);
//Update patterns
if (!name) return EINA_FALSE;
- _edje_if_string_free(ed, epr->sample_name);
- epr->sample_name = eina_stringshare_add(name);
+ _edje_if_string_replace(ed, &epr->sample_name, name);
return EINA_TRUE;
}
if (!name) return EINA_FALSE;
- _edje_if_string_free(ed, epr->tone_name);
- epr->tone_name = eina_stringshare_add(name);
+ _edje_if_string_replace(ed, &epr->tone_name, name);
return EINA_TRUE;
}
if (!filter_part) return EINA_FALSE;
- _edje_if_string_free(ed, epr->filter.part);
- epr->filter.part = eina_stringshare_add(filter_part);
+ _edje_if_string_replace(ed, &epr->filter.part, filter_part);
return EINA_TRUE;
}
if (!filter_state) return EINA_FALSE;
- _edje_if_string_free(ed, epr->filter.state);
- epr->filter.state = eina_stringshare_add(filter_state);
+ _edje_if_string_replace(ed, &epr->filter.state, filter_state);
return EINA_TRUE;
}
/* Remove from program array */
_edje_program_remove(ed->collection, epr);
- _edje_if_string_free(ed, epr->signal);
/* Insert it back */
- epr->signal = eina_stringshare_add(sig);
+ _edje_if_string_replace(ed, &epr->signal, sig);
_edje_program_insert(ed->collection, epr);
//Update patterns
//printf("SET STATE for program: %s\n", prog);
- _edje_if_string_free(ed, epr->state);
- epr->state = eina_stringshare_add(state);
+ _edje_if_string_replace(ed, &epr->state, state);
return EINA_TRUE;
}
//printf("SET STATE2 for program: %s\n", prog);
- _edje_if_string_free(ed, epr->state2);
- epr->state2 = eina_stringshare_add(state2);
+ _edje_if_string_replace(ed, &epr->state2, state2);
return EINA_TRUE;
}
GET_ED_OR_RETURN(EINA_FALSE);
GET_EPR_OR_RETURN(EINA_FALSE);
- _edje_if_string_free(ed, epr->api.name);
- epr->api.name = eina_stringshare_add(name);
+ _edje_if_string_replace(ed, &epr->api.name, name);
return EINA_TRUE;
}
GET_ED_OR_RETURN(EINA_FALSE);
GET_EPR_OR_RETURN(EINA_FALSE);
- _edje_if_string_free(ed, epr->api.description);
- epr->api.description = eina_stringshare_add(description);
+ _edje_if_string_replace(ed, &epr->api.description, description);
return EINA_TRUE;
}
/* Set compiler name */
if (strcmp(ef->compiler, "edje_edit"))
- {
- _edje_if_string_free(ed, ef->compiler);
- ef->compiler = (char *)eina_stringshare_add("edje_edit");
- }
+ _edje_if_string_replace(ed, &ef->compiler, "edje_edit");
if (!_edje_edit_edje_file_save(eetf, ef))
{