forked from enlightenment/efl
elementary/genlist, gengrid - added itc version checking.
SVN revision: 68539
This commit is contained in:
parent
f2c4e9b2f5
commit
0759538f5e
|
@ -11,7 +11,6 @@ struct _Elm_Gen_Item_Class
|
|||
{
|
||||
int version;
|
||||
unsigned int refcount;
|
||||
Eina_Bool delete_me : 1;
|
||||
const char *item_style;
|
||||
const char *mode_item_style;
|
||||
const char *edit_item_style;
|
||||
|
@ -22,4 +21,5 @@ struct _Elm_Gen_Item_Class
|
|||
Elm_Gen_Item_State_Get_Cb state_get;
|
||||
Elm_Gen_Item_Del_Cb del;
|
||||
} func;
|
||||
Eina_Bool delete_me : 1;
|
||||
};
|
||||
|
|
|
@ -21,6 +21,23 @@
|
|||
(it)->unsel_cb = (Ecore_Cb)_item_unselect; \
|
||||
(it)->unrealize_cb = (Ecore_Cb)_item_unrealize_cb
|
||||
|
||||
#define ELM_GENGRID_CHECK_ITC_VER(itc) \
|
||||
do \
|
||||
{ \
|
||||
if (!itc) \
|
||||
{ \
|
||||
ERR("Gengrid_Item_Class(itc) is NULL"); \
|
||||
return; \
|
||||
} \
|
||||
if (itc->version != ELM_GENGRID_ITEM_CLASS_VERSION) \
|
||||
{ \
|
||||
ERR("Gengrid_Item_Class version mismatched! required = (%d), current = (%d)", itc->version, ELM_GENGRID_ITEM_CLASS_VERSION); \
|
||||
return; \
|
||||
} \
|
||||
} \
|
||||
while(0)
|
||||
|
||||
|
||||
struct Elm_Gen_Item_Type
|
||||
{
|
||||
Elm_Gen_Item *it;
|
||||
|
@ -2782,12 +2799,10 @@ elm_gengrid_item_class_new(void)
|
|||
return itc;
|
||||
}
|
||||
|
||||
//XXX: notify class version to user if it is mismatched
|
||||
EAPI void
|
||||
elm_gengrid_item_class_free(Elm_Gengrid_Item_Class *itc)
|
||||
{
|
||||
if (itc && (itc->version == ELM_GENGRID_ITEM_CLASS_VERSION))
|
||||
{
|
||||
ELM_GENGRID_CHECK_ITC_VER(itc);
|
||||
if (!itc->delete_me) itc->delete_me = EINA_TRUE;
|
||||
if (itc->refcount > 0) elm_gengrid_item_class_unref(itc);
|
||||
else
|
||||
|
@ -2796,28 +2811,23 @@ elm_gengrid_item_class_free(Elm_Gengrid_Item_Class *itc)
|
|||
free(itc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//XXX: notify class version to user if it is mismatched
|
||||
EAPI void
|
||||
elm_gengrid_item_class_ref(Elm_Gengrid_Item_Class *itc)
|
||||
{
|
||||
if (itc && (itc->version == ELM_GENGRID_ITEM_CLASS_VERSION))
|
||||
{
|
||||
ELM_GENGRID_CHECK_ITC_VER(itc);
|
||||
|
||||
itc->refcount++;
|
||||
if (itc->refcount == 0) itc->refcount--;
|
||||
}
|
||||
}
|
||||
|
||||
//XXX: notify class version to user if it is mismatched
|
||||
EAPI void
|
||||
elm_gengrid_item_class_unref(Elm_Gengrid_Item_Class *itc)
|
||||
{
|
||||
if (itc && (itc->version == ELM_GENGRID_ITEM_CLASS_VERSION))
|
||||
{
|
||||
ELM_GENGRID_CHECK_ITC_VER(itc);
|
||||
|
||||
if (itc->refcount > 0) itc->refcount--;
|
||||
if (itc->delete_me && (!itc->refcount))
|
||||
elm_gengrid_item_class_free(itc);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -21,6 +21,24 @@
|
|||
(it)->unhighlight_cb = (Ecore_Cb)_item_unhighlight; \
|
||||
(it)->unrealize_cb = (Ecore_Cb)_item_unrealize_cb
|
||||
|
||||
#define ELM_GENLIST_CHECK_ITC_VER(itc) \
|
||||
do \
|
||||
{ \
|
||||
if (!itc) \
|
||||
{ \
|
||||
ERR("Genlist_Item_Class(itc) is NULL"); \
|
||||
return; \
|
||||
} \
|
||||
if (itc->version != ELM_GENLIST_ITEM_CLASS_VERSION) \
|
||||
{ \
|
||||
ERR("Genlist_Item_Class version mismatched! required = (%d), current = (%d)", itc->version, ELM_GENLIST_ITEM_CLASS_VERSION); \
|
||||
return; \
|
||||
} \
|
||||
} \
|
||||
while(0)
|
||||
|
||||
|
||||
|
||||
typedef struct _Item_Block Item_Block;
|
||||
typedef struct _Item_Cache Item_Cache;
|
||||
|
||||
|
@ -5603,12 +5621,10 @@ elm_genlist_item_class_new(void)
|
|||
return itc;
|
||||
}
|
||||
|
||||
//XXX: notify the class version if it is mismatched
|
||||
EAPI void
|
||||
elm_genlist_item_class_free(Elm_Genlist_Item_Class *itc)
|
||||
{
|
||||
if (itc && (itc->version == ELM_GENLIST_ITEM_CLASS_VERSION))
|
||||
{
|
||||
ELM_GENLIST_CHECK_ITC_VER(itc);
|
||||
if (!itc->delete_me) itc->delete_me = EINA_TRUE;
|
||||
if (itc->refcount > 0) elm_genlist_item_class_unref(itc);
|
||||
else
|
||||
|
@ -5617,30 +5633,25 @@ elm_genlist_item_class_free(Elm_Genlist_Item_Class *itc)
|
|||
free(itc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//XXX: notify the class version if it is mismatched
|
||||
EAPI void
|
||||
elm_genlist_item_class_ref(Elm_Genlist_Item_Class *itc)
|
||||
{
|
||||
if (itc && (itc->version == ELM_GENLIST_ITEM_CLASS_VERSION))
|
||||
{
|
||||
ELM_GENLIST_CHECK_ITC_VER(itc);
|
||||
|
||||
itc->refcount++;
|
||||
if (itc->refcount == 0) itc->refcount--;
|
||||
}
|
||||
}
|
||||
|
||||
//XXX: notify the class version if it is mismatched
|
||||
EAPI void
|
||||
elm_genlist_item_class_unref(Elm_Genlist_Item_Class *itc)
|
||||
{
|
||||
if (itc && (itc->version == ELM_GENLIST_ITEM_CLASS_VERSION))
|
||||
{
|
||||
ELM_GENLIST_CHECK_ITC_VER(itc);
|
||||
|
||||
if (itc->refcount > 0) itc->refcount--;
|
||||
if (itc->delete_me && (!itc->refcount))
|
||||
elm_genlist_item_class_free(itc);
|
||||
}
|
||||
}
|
||||
|
||||
/* for gengrid as of now */
|
||||
void
|
||||
|
|
Loading…
Reference in New Issue