*/
virtual void onCreated() { }
+ /**
+ * @brief Called before Control is destroyed.
+ */
+ virtual void onDestroy() { }
+
private:
void setEvasObject(Evas_Object *object);
Evas_Object *resetEvasObject();
void destroyEvasObject();
- void onDestroy(Evas *e, Evas_Object *obj, void *event_info);
+ void onDestroyed(Evas *e, Evas_Object *obj, void *event_info);
int m_Type;
Evas_Object *m_Object;
evas_object_data_set(m_Object, CONTROL_DATA_KEY, this);
}
+ evas_object_event_callback_add(m_Object, EVAS_CALLBACK_DEL,
+ (Evas_Object_Event_Cb) makeCallback(&Control::onDestroy), this);
evas_object_event_callback_add(m_Object, EVAS_CALLBACK_FREE,
- makeCallback(&Control::onDestroy), this);
+ makeCallback(&Control::onDestroyed), this);
}
Evas_Object *Control::resetEvasObject()
{
Evas_Object *object = m_Object;
+ evas_object_event_callback_del_full(m_Object, EVAS_CALLBACK_DEL,
+ (Evas_Object_Event_Cb) makeCallback(&Control::onDestroy), this);
evas_object_event_callback_del_full(m_Object, EVAS_CALLBACK_FREE,
- makeCallback(&Control::onDestroy), this);
+ makeCallback(&Control::onDestroyed), this);
m_Object = nullptr;
return object;
}
void Control::destroyEvasObject()
{
if (m_Object) {
+ onDestroy();
evas_object_del(resetEvasObject());
}
}
-void Control::onDestroy(Evas *e, Evas_Object *obj, void *event_info)
+void Control::onDestroyed(Evas *e, Evas_Object *obj, void *event_info)
{
- resetEvasObject();
+ m_Object = nullptr;
delete this;
}
};
virtual Evas_Object *onCreate(Evas_Object *parent) override;
- virtual void onNavigation(bool isCurrent) override;
virtual void onCreated() override;
+ virtual void onDestroy() override;
+
+ virtual void onNavigation(bool isCurrent) override;
virtual void onMenuPressed() override;
void onDeleteSelected();
return layout;
}
-void ListView::onNavigation(bool isCurrent)
-{
- m_IsCurrentView = isCurrent;
- updateAddButton();
- m_Provider.setUpdateMode(isCurrent);
-}
-
void ListView::onCreated()
{
updateSectionsMode();
contacts_setting_add_name_sorting_order_changed_cb(onNameSortingOrderChanged, this);
}
+void ListView::onDestroy()
+{
+ for (auto &§ion : m_Sections) {
+ if (section && !section->isInserted()) {
+ delete section;
+ }
+ }
+}
+
+void ListView::onNavigation(bool isCurrent)
+{
+ m_IsCurrentView = isCurrent;
+ updateAddButton();
+ m_Provider.setUpdateMode(isCurrent);
+}
+
void ListView::onMenuPressed()
{
if (getSelectMode() != SelectNone) {