entry: elm_entry_markup_filter_remove() has a problem when internally defined filters are used. fixed.

When we call elm_entry_markup_filter_remove() with internally defined filter callbacks,
it doesn't work. So we need a one of pointer for saving the address of data.

10 Elm_Entry_Filter_Limit_Size lim;
11 lim.max_char_count = 20;
12 lim.max_byte_count = 0;
13 elm_entry_markup_filter_append(en, elm_entry_filter_limit_size,
&lim);
14
15 elm_entry_markup_filter_remove(en, elm_entry_filter_limit_size,
&lim);
16 lim.max_char_count = 50;
17 lim.max_byte_count = 0;
18 elm_entry_markup_filter_append(en, elm_entry_filter_limit_size,
&lim);

In this code, we expect to see the filter of entry will be renewed.
But elm_entry_markup_filter_remove() doesn't work.
Because, markup_filter does not hold the address of data when we use
the filter callback which is defined in elm_entry.c

_filter_new() in elm_entry.c
You can see that _filter_new allocates new pointer and names as lim2.
lim2 is saved in data of _Elm_Entry_Markup_Filter. So the address of
data doesn't equal to the input data.
This commit is contained in:
Youngbok Shin 2013-05-16 18:10:13 +09:00 committed by Carsten Haitzler (Rasterman)
parent 56b5974327
commit e847b65e2f
2 changed files with 3 additions and 1 deletions

View File

@ -310,6 +310,7 @@ _filter_new(Elm_Entry_Filter_Cb func,
if (!tf) return NULL;
tf->func = func;
tf->orig_data = data;
if (func == elm_entry_filter_limit_size)
{
Elm_Entry_Filter_Limit_Size *lim = data, *lim2;
@ -4190,7 +4191,7 @@ _markup_filter_remove(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
EINA_LIST_FOREACH(sd->markup_filters, l, tf)
{
if ((tf->func == func) && ((!data) || (tf->data == data)))
if ((tf->func == func) && ((!data) || (tf->orig_data == data)))
{
sd->markup_filters = eina_list_remove_list(sd->markup_filters, l);
_filter_free(tf);

View File

@ -116,6 +116,7 @@ struct _Elm_Entry_Markup_Filter
{
Elm_Entry_Filter_Cb func;
void *data;
void *orig_data;
};
typedef enum _Length_Unit