From: Hermet Park Date: Mon, 23 May 2016 15:36:01 +0000 (+0900) Subject: fix the unstable life-cycle behavior. X-Git-Tag: submit/tizen/20160617.075742~32 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=df1f29f6c1e5e8c409a505b56c8e8a8db06f839d;p=platform%2Fcore%2Fuifw%2Fui-viewmgr.git fix the unstable life-cycle behavior. test & implement ui_view life-cycle behaviors. Change-Id: Id6847f6dc8f24dd721360c5c4c6c08ffe81398e6 --- diff --git a/src/examples/efl/page1.h b/src/examples/efl/page1.h index 97c1701..252c528 100644 --- a/src/examples/efl/page1.h +++ b/src/examples/efl/page1.h @@ -41,6 +41,30 @@ protected: this->set_content(content, "Page1"); } + //on_unload() will be called when this page1 is requested to be hidden. + void on_unload() + { + ui_standard_view::on_unload(); + } + + //on_destroy() will be called when this page1 is requested to be destroyed. + void on_destroy() + { + ui_standard_view::on_destroy(); + } + + //on_deactivate() will be called when this page1 is requested to be deactivated. + void on_deactivate() + { + ui_standard_view::on_deactivate(); + } + + //on_activate() will be called when this page1 is requested to be activated. + void on_activate() + { + ui_standard_view::on_activate(); + } + public: page1() : ui_standard_view("page1") {} ~page1() {} diff --git a/src/examples/efl/page2.h b/src/examples/efl/page2.h index ae4b496..37f27d9 100644 --- a/src/examples/efl/page2.h +++ b/src/examples/efl/page2.h @@ -20,6 +20,11 @@ */ class page2: public ui_standard_view { +private: + Evas_Object *content; + Elm_Button *left_title_btn; + Elm_Button *right_title_btn; + protected: void on_load() { @@ -48,9 +53,23 @@ protected: //Arguments: content, title, subtitle, title left button, title right button this->set_content(content, "Page2", NULL, left_title_btn, right_title_btn); + + this->content = content; + this->left_title_btn = left_title_btn; + this->right_title_btn = right_title_btn; + } + void on_unload() + { + ui_standard_view::on_unload(); + + evas_object_del(this->content); + evas_object_del(this->left_title_btn); + evas_object_del(this->right_title_btn); } public: - page2() : ui_standard_view("page2") {} + page2() : ui_standard_view("page2") + { + } ~page2() {} }; diff --git a/src/include/efl/mobile/ui_mobile_viewmanager.h b/src/include/efl/mobile/ui_mobile_viewmanager.h index 3c8da4b..62841ea 100644 --- a/src/include/efl/mobile/ui_mobile_viewmanager.h +++ b/src/include/efl/mobile/ui_mobile_viewmanager.h @@ -17,7 +17,6 @@ #ifndef _UI_MOBILE_VIEWMANAGER_H_ #define _UI_MOBILE_VIEWMANAGER_H_ -#include #include "../ui_base_viewmanager.h" #include "ui_view.h" #include "ui_standard_view.h" diff --git a/src/include/efl/ui_base_viewmanager.h b/src/include/efl/ui_base_viewmanager.h index 6b5f37e..ff4f840 100644 --- a/src/include/efl/ui_base_viewmanager.h +++ b/src/include/efl/ui_base_viewmanager.h @@ -22,6 +22,7 @@ #define Elm_Conformant Evas_Object #endif +#include #include "../interface/ui_iface_viewmanager.h" #include "ui_base_overlay.h" #include "ui_base_key_listener.h" diff --git a/src/include/interface/ui_iface_view.h b/src/include/interface/ui_iface_view.h index b162382..7107eb2 100644 --- a/src/include/interface/ui_iface_view.h +++ b/src/include/interface/ui_iface_view.h @@ -245,7 +245,7 @@ protected: * @brief View destroy state. * * @note When this view is on destroyed by popping or by somehow, destroy will be triggered. Most of the cases, you can free your personal resources for - * the view because this view instance will be totally freed at the end of destroy. Be awre that you must not request any view functions on this + * the view because this view instance will be totally freed at the end of destroy. Be aware that you must not request any view functions on this * state. */ virtual void on_destroy(); diff --git a/src/lib/efl/mobile/ui_app.cpp b/src/lib/efl/mobile/ui_app.cpp index 2bf7853..0737421 100644 --- a/src/lib/efl/mobile/ui_app.cpp +++ b/src/lib/efl/mobile/ui_app.cpp @@ -278,7 +278,7 @@ void ui_app::on_pause() void ui_app::on_resume() { - this->impl->get_viewmgr()->activate(); +// this->impl->get_viewmgr()->activate(); } void ui_app::on_control(app_control_h app_control) @@ -289,6 +289,7 @@ void ui_app::on_control(app_control_h app_control) void ui_app::on_terminate() { + delete(this); } ui_app::ui_app(const char *pkg, const char *locale_dir) diff --git a/src/lib/efl/ui_base_viewmgr.cpp b/src/lib/efl/ui_base_viewmgr.cpp index c8d52a0..daddf2a 100644 --- a/src/lib/efl/ui_base_viewmgr.cpp +++ b/src/lib/efl/ui_base_viewmgr.cpp @@ -294,8 +294,6 @@ ui_base_viewmgr_impl::ui_base_viewmgr_impl(ui_base_viewmgr *viewmgr, const char { ui_base_viewmgr *viewmgr = static_cast(data); delete(viewmgr); - //FIXME: Window is destroyed. Terminate Application! - //ui_app_exit(); }, this->viewmgr); @@ -343,11 +341,6 @@ bool ui_base_viewmgr_impl::term() bool ui_base_viewmgr_impl::activate() { this->activate_top_view(); - - //FIXME: Necessary?? - ui_base_view *view = this->viewmgr->get_last_view(); - view->on_activate(); - evas_object_show(this->win); return true; @@ -358,14 +351,11 @@ bool ui_base_viewmgr_impl::deactivate() //FIXME: based on the profile, we should app to go behind or terminate. if (true) { - ui_base_view *view = this->viewmgr->get_last_view(); - if (view) view->on_deactivate(); evas_object_lower(this->win); } else { - //FIXME: exit app - //ui_app_exit(); + delete(this->viewmgr); } return true; @@ -376,7 +366,7 @@ bool ui_base_viewmgr_impl::pop_view() ui_base_view *pview = this->viewmgr->get_view(this->viewmgr->get_view_count() - 2); ui_base_view *view = this->viewmgr->get_last_view(); - //In case, if view doesn't have transition effect + //In case, if view doesn't have any transition effects. if (!strcmp(view->get_transition_style(), "none")) { this->viewmgr->pop_view_finished(pview); @@ -474,12 +464,12 @@ ui_base_viewmgr::~ui_base_viewmgr() { this->impl->term(); delete(this->impl); + ui_app_exit(); } bool ui_base_viewmgr::activate() { if (!ui_iface_viewmgr::activate()) return false; - this->impl->activate(); return true; @@ -488,7 +478,6 @@ bool ui_base_viewmgr::activate() bool ui_base_viewmgr::deactivate() { if (!ui_iface_viewmgr::deactivate()) return false; - this->impl->deactivate(); return true; diff --git a/src/lib/interface/ui_iface_view.cpp b/src/lib/interface/ui_iface_view.cpp index f62e273..37aeb96 100644 --- a/src/lib/interface/ui_iface_view.cpp +++ b/src/lib/interface/ui_iface_view.cpp @@ -121,6 +121,7 @@ void ui_iface_view_impl::on_resume() void ui_iface_view_impl::on_destroy() { + } ui_iface_view_impl::ui_iface_view_impl(ui_iface_view *view, const char *name) diff --git a/src/lib/interface/ui_iface_viewmgr.cpp b/src/lib/interface/ui_iface_viewmgr.cpp index bbe8254..5669538 100644 --- a/src/lib/interface/ui_iface_viewmgr.cpp +++ b/src/lib/interface/ui_iface_viewmgr.cpp @@ -38,6 +38,7 @@ private: static bool event_block; //Event block on view transition. This value should be configurable by system. list view_list; //View list. bool activated; //Activated status of this viewmgr. + bool destroying; //True, if viewmgr is on destroying. public: bool connect_view(ui_iface_view *view); @@ -182,7 +183,7 @@ bool ui_iface_viewmgr_impl::pop_view_finished(ui_iface_view *view) } ui_iface_viewmgr_impl::ui_iface_viewmgr_impl(ui_iface_viewmgr* viewmgr) - : activated(false) + : activated(false), destroying(false) { ui_iface_viewmgr_impl::inst = viewmgr; } @@ -190,14 +191,23 @@ ui_iface_viewmgr_impl::ui_iface_viewmgr_impl(ui_iface_viewmgr* viewmgr) ui_iface_viewmgr_impl::~ui_iface_viewmgr_impl() { //Terminate views - for (VIEW_RITR it = this->view_list.rbegin(); it != this->view_list.rend(); it++) + this->destroying = EINA_TRUE; + for (VIEW_RITR ritr = this->view_list.rbegin(); ritr != this->view_list.rend(); ritr++) { - ui_iface_view *view = *it; - view->on_deactivate(); - view->on_unload(); + ui_iface_view *view = *ritr; + if ((view->get_state() != UI_VIEW_STATE_DEACTIVATE) && + (view->get_state() != UI_VIEW_STATE_UNLOAD)) + { + view->on_deactivate(); + } + if (view->get_state() != UI_VIEW_STATE_UNLOAD) + { + view->on_unload(); + } view->on_destroy(); delete (view); } + this->destroying = EINA_FALSE; //FIXME: Window is destroyed. Terminate Application! ui_app_exit(); @@ -231,11 +241,10 @@ ui_iface_view *ui_iface_viewmgr_impl::push_view(ui_iface_view *view) this->view_list.push_back(view); - if (!view->get_content()) - { - view->on_load(); - } + //If view manager is not activated yet, don't load view. + if (!this->is_activated()) return view; + view->on_load(); view->on_deactivate(); if (this->view_list.size() != 1) @@ -329,6 +338,8 @@ bool ui_iface_viewmgr_impl::insert_view_before(ui_iface_view *view, ui_iface_vie bool ui_iface_viewmgr_impl::remove_view(ui_iface_view *view) { + if (this->destroying) return false; + this->view_list.remove(view); this->disconnect_view(view); @@ -372,6 +383,10 @@ bool ui_iface_viewmgr_impl::activate() if (this->activated) return false; if (this->get_view_count() == 0) return false; this->activated = true; + ui_iface_view *view = this->get_last_view(); + view->on_load(); + view->on_deactivate(); + view->on_activate(); return true; } @@ -379,6 +394,18 @@ bool ui_iface_viewmgr_impl::deactivate() { if (!this->activated) return false; this->activated = false; + ui_iface_view *view = this->get_last_view(); + + if ((view->get_state() != UI_VIEW_STATE_DEACTIVATE) && + (view->get_state() != UI_VIEW_STATE_UNLOAD)) + { + view->on_deactivate(); + } + if (view->get_state() != UI_VIEW_STATE_UNLOAD) + { + view->on_unload(); + } + return true; }