I am trying to create radio buttons in a genlist. I am able to succesfully create the genlist, add several items, and add radio buttons onto the items. That works fine.
However, if I try to add the radio buttons to a group (in the get content callback), I get a segfault (see the line below with SEGFAULT comment) when adding the button to the group. I confirmed that m_group is properly set to the address of the last radio button added.
Evas_Object* TTL_GenList_Radio::cb_entry_icon_get(void *id, Evas_Object *obj, const char *part) { return ((TTL_GenList_Radio*)((Titem_data*)id)->thisGenlist)->entry_icon_get((Titem_data*) id, obj, std::string(part)); } Evas_Object* TTL_GenList_Radio::entry_icon_get(Titem_data* id, Evas_Object *obj, const std::string part) { if (part != "elm.swallow.end") return NULL; // Add the button to the genlist item Evas_Object* radio = elm_radio_add(obj); elm_radio_state_value_set(radio, id->buttonValue); // Add to group (or set first button as group) if (m_group == nullptr) m_group = radio; else elm_radio_group_add(radio, m_group); // SEGFAULT HERE evas_object_show(radio); // Set callback for changed function evas_object_smart_callback_add(radio, "changed", TTL_GenList_Radio::cb_changed, this); return radio; }
Can someone explain why I am segfaulting when adding the radio to the group? (I made a simple standalone example of adding radio buttons to a box, and groupping them, and that worked fine)
I suspect it has something to do with the 'get content callback' function. Is the passed in object released after it is rendered - which causes the button to be released? That would explain why trying to group with the (now released) previous button results in a segfault. I just don't know how to solve this.