seoz pushed a commit to branch master.
commit 267670fc8a9f4cd49e43db8751bd2b2e2c398a24
Author: Daniel Juyung Seo <[email protected]>
Date: Wed May 8 20:50:05 2013 +0900
test_genlist.c: use elm_genlist_item_class_free in a better way.
---
src/bin/test_genlist.c | 34 ++++++++++++++++++++++++++++------
1 file changed, 28 insertions(+), 6 deletions(-)
diff --git a/src/bin/test_genlist.c b/src/bin/test_genlist.c
index cef408d..ec64d84 100644
--- a/src/bin/test_genlist.c
+++ b/src/bin/test_genlist.c
@@ -361,7 +361,12 @@ my_gl_add(void *data, Evas_Object *obj __UNUSED__, void
*event_info __UNUSED__)
Evas_Object *gl = data;
static int i = 0;
- if (!itc1) itc1 = elm_genlist_item_class_new();
+ if (!itc1)
+ {
+ ERR("Genlist item class should not be null. Something very bad is
happening!!");
+ return;
+ }
+
itc1->item_style = "default";
itc1->func.text_get = gl_text_get;
itc1->func.content_get = gl_content_get;
@@ -384,7 +389,12 @@ my_gl_insert_before(void *data, Evas_Object *obj
__UNUSED__, void *event_info __
static int i = 0;
Elm_Object_Item *gli_selected;
- if (!itc1) itc1 = elm_genlist_item_class_new();
+ if (!itc1)
+ {
+ ERR("Genlist item class should not be null. Something very bad is
happening!!");
+ return;
+ }
+
itc1->item_style = "default";
itc1->func.text_get = gl_text_get;
itc1->func.content_get = gl_content_get;
@@ -415,7 +425,12 @@ my_gl_insert_after(void *data, Evas_Object *obj
__UNUSED__, void *event_info __U
static int i = 0;
Elm_Object_Item *gli_selected;
- if (!itc1) itc1 = elm_genlist_item_class_new();
+ if (!itc1)
+ {
+ ERR("Genlist item class should not be null. Something very bad is
happening!!");
+ return;
+ }
+
itc1->item_style = "default";
itc1->func.text_get = gl_text_get;
itc1->func.content_get = gl_content_get;
@@ -515,6 +530,15 @@ my_gl_flush(void *data __UNUSED__, Evas_Object *obj
__UNUSED__, void *event_info
ecore_timer_add(1.2, my_gl_flush_delay, NULL);
}
+static void
+_genlist_del_cb(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__,
+ void *event_info __UNUSED__)
+{
+ if (!data) return;
+
+ elm_genlist_item_class_free(data);
+}
+
void
test_genlist2(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void
*event_info __UNUSED__)
{
@@ -681,9 +705,7 @@ test_genlist2(void *data __UNUSED__, Evas_Object *obj
__UNUSED__, void *event_in
elm_box_pack_end(bx, bx3);
evas_object_show(bx3);
- /* item_class_ref is needed for itc1. some items can be added in callbacks
*/
- elm_genlist_item_class_ref(itc1);
- elm_genlist_item_class_free(itc1);
+ evas_object_event_callback_add(gl, EVAS_CALLBACK_DEL, _genlist_del_cb,
itc1);
evas_object_resize(win, 320, 320);
evas_object_show(win);
--
------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and
their applications. This 200-page book is written by three acclaimed
leaders in the field. The early access version is available now.
Download your free book today! http://p.sf.net/sfu/neotech_d2d_may