I am having problem with double execution of the text_get callback function for genlists.
If I have the following code in a button callback function to add an entry to genlist log_list
char* entry_display; ... dlog_print(DLOG_DEBUG, LOG_TAG, "button clicked"); Elm_Genlist_Item_Class *itc = elm_genlist_item_class_new(); itc->item_style = "type1"; itc->func.text_get = _item_label_get; itc->func.content_get = NULL; itc->func.state_get = NULL; itc->func.del = NULL; elm_genlist_item_prepend(ad_change->log_list, itc, entry_display, NULL,ELM_GENLIST_ITEM_NONE, NULL, NULL);
and the _item_label_get function:
char * _item_label_get(void *data, Evas_Object *obj, const char *part) { char* this_item; this_item = data; dlog_print(DLOG_DEBUG, LOG_TAG, data); dlog_print(DLOG_DEBUG, LOG_TAG, part); if (!strcmp(part, "elm.text")) { return strdup(data); } else return NULL; }
This is what I get from the device log:
D/APP_TAG ( 3207): button clicked D/APP_TAG ( 3207): test D/APP_TAG ( 3207): elm.text D/APP_TAG ( 3207): test D/APP_TAG ( 3207): elm.text.end D/APP_TAG ( 3207): test D/APP_TAG ( 3207): elm.text.sub D/APP_TAG ( 3207): test D/APP_TAG ( 3207): elm.text.sub.end D/APP_TAG ( 3207): test D/APP_TAG ( 3207): elm.text D/APP_TAG ( 3207): test D/APP_TAG ( 3207): elm.text.end D/APP_TAG ( 3207): test D/APP_TAG ( 3207): elm.text.sub D/APP_TAG ( 3207): test D/APP_TAG ( 3207): elm.text.sub.end
The function is apparently called twice for each element. This does not alter the behavior in this case but if I change the data pointer to the struct:
typedef struct{ char* time; char* log_name; }log_item;
And the debug logging to:
dlog_print(DLOG_DEBUG, LOG_TAG, this_item->log_name); dlog_print(DLOG_DEBUG, LOG_TAG, this_item->time);
I get this in the device log:
D/APP_TAG ( 3257): button clicked D/APP_TAG ( 3257): test2 D/APP_TAG ( 3257): 2016-01-20 08:51:42 D/APP_TAG ( 3257): test2 D/APP_TAG ( 3257): 2016-01-20 08:51:42 D/APP_TAG ( 3257): test2 D/APP_TAG ( 3257): 2016-01-20 08:51:42 D/APP_TAG ( 3257): test2 D/APP_TAG ( 3257): 2016-01-20 08:51:42 D/APP_TAG ( 3257): È7ַp¸۷ð}ݷðjܷ D/APP_TAG ( 3257): ð}ݷðjܷ D/APP_TAG ( 3257): È7ַð}ݷèVڷðjܷ D/APP_TAG ( 3257): èVڷðjܷ D/APP_TAG ( 3257): È7ַð}ݷèVڷðjܷ D/APP_TAG ( 3257): èVڷðjܷ D/APP_TAG ( 3257): È7ַð}ݷèVڷðjܷ D/APP_TAG ( 3257): èVڷðjܷ
Obiously the genlist does not look pretty. This looks like undefined behavior am I missing something?
The application is compiled with 2.4 rev 2 sdk.