From 7dc4a2ecff73c999dc4d71d7263646c2e55919d2 Mon Sep 17 00:00:00 2001 From: Hermet Park Date: Tue, 29 Nov 2016 21:21:30 +0900 Subject: [PATCH] Fix corner cases of view life cycle. View life-cycle hasn't been tested strictly. So, I tested it and fix all corner cases that I could find. Change-Id: Ia18c3b029e0302487978a03cb6e136d13f5b1ebf --- src/include/interface/UiIfaceOverlay.h | 4 ++-- src/include/interface/UiIfaceView.h | 1 + src/lib/efl/mobile/UiMenu.cpp | 11 +++++++---- src/lib/efl/mobile/UiPopup.cpp | 11 ++++++----- src/lib/interface/UiIfaceOverlay.cpp | 15 ++++++++++++++- src/lib/interface/UiIfaceView.cpp | 2 +- src/lib/interface/UiIfaceViewmgr.cpp | 8 +++----- 7 files changed, 34 insertions(+), 18 deletions(-) diff --git a/src/include/interface/UiIfaceOverlay.h b/src/include/interface/UiIfaceOverlay.h index 44b8311..bc15461 100644 --- a/src/include/interface/UiIfaceOverlay.h +++ b/src/include/interface/UiIfaceOverlay.h @@ -75,7 +75,7 @@ public: * * @see deactivate() */ - virtual int activate() = 0; + virtual int activate(); /** * @brief Overlay deactivate. @@ -86,7 +86,7 @@ public: * * @see activate() */ - virtual int deactivate() = 0; + virtual int deactivate(); /** * @brief Returns the active status of overlay. diff --git a/src/include/interface/UiIfaceView.h b/src/include/interface/UiIfaceView.h index 3461106..678193f 100644 --- a/src/include/interface/UiIfaceView.h +++ b/src/include/interface/UiIfaceView.h @@ -362,6 +362,7 @@ private: _UI_DECLARE_PRIVATE_IMPL(UiIfaceView); _UI_DECLARE_FRIENDS(UiIfaceViewmgr); _UI_DECLARE_FRIENDS(UiIfaceApp); + _UI_DECLARE_FRIENDS(UiIfaceOverlay); }; } diff --git a/src/lib/efl/mobile/UiMenu.cpp b/src/lib/efl/mobile/UiMenu.cpp index c3f5595..4f530d8 100644 --- a/src/lib/efl/mobile/UiMenu.cpp +++ b/src/lib/efl/mobile/UiMenu.cpp @@ -30,7 +30,7 @@ static void _ctxpopupDelCb(void *data, Evas *e, Eo *obj, void *event_info) menu->unsetContent(); } -static bool _updateMenu(UiMenu *menu) +static int _updateMenu(UiMenu *menu) { Elm_Win *win = menu->getBase(); if (!win) return UI_VIEWMGR_ERROR_NOT_PERMITTED; @@ -104,14 +104,17 @@ int UiMenu::deactivate() } elm_ctxpopup_dismiss(ctxpopup); - dynamic_cast(this->getView())->onResume(); - return UI_VIEWMGR_ERROR_NONE; + return UiBaseOverlay::deactivate(); } int UiMenu::activate() { - bool ret = _updateMenu(this); + int ret = UiBaseOverlay::activate(); + + if (ret != UI_VIEWMGR_ERROR_NONE) return ret; + + ret = _updateMenu(this); if (ret != UI_VIEWMGR_ERROR_NONE) dynamic_cast(this->getView())->onPause(); return ret; diff --git a/src/lib/efl/mobile/UiPopup.cpp b/src/lib/efl/mobile/UiPopup.cpp index aa00d4e..1c62b94 100644 --- a/src/lib/efl/mobile/UiPopup.cpp +++ b/src/lib/efl/mobile/UiPopup.cpp @@ -21,7 +21,7 @@ using namespace efl_viewmanager; static int _updatePopup(UiPopup *popup) { - if (popup->getView()->getState() != UI_VIEW_STATE_ACTIVATE) + if (popup->getView()->getState() != UI_VIEW_STATE_PAUSE) return UI_VIEWMGR_ERROR_NOT_PERMITTED; Elm_Win *win = popup->getBase(); @@ -82,15 +82,16 @@ int UiPopup::deactivate() } elm_popup_dismiss(popup); - dynamic_cast(this->getView())->onResume(); - return UI_VIEWMGR_ERROR_NONE; + return UiBaseOverlay::deactivate(); } int UiPopup::activate() { - int ret = _updatePopup(this); - if (ret != UI_VIEWMGR_ERROR_NONE) dynamic_cast(this->getView())->onPause(); + int ret = UiBaseOverlay::activate(); + if (ret != UI_VIEWMGR_ERROR_NONE) return ret; + + ret = _updatePopup(this); return ret; } diff --git a/src/lib/interface/UiIfaceOverlay.cpp b/src/lib/interface/UiIfaceOverlay.cpp index b5fc461..5b7c76b 100644 --- a/src/lib/interface/UiIfaceOverlay.cpp +++ b/src/lib/interface/UiIfaceOverlay.cpp @@ -78,7 +78,6 @@ UiIfaceView *UiIfaceOverlayImpl::getView() const noexcept return this->_view; } - /***********************************************************************************************/ /* External class Implementation */ /***********************************************************************************************/ @@ -116,3 +115,17 @@ void UiIfaceOverlay::onBack() { this->deactivate(); } + +int UiIfaceOverlay::activate() +{ + this->_impl->_view->onPause(); + + return UI_VIEWMGR_ERROR_NONE; +} + +int UiIfaceOverlay::deactivate() +{ + this->_impl->_view->onResume(); + + return UI_VIEWMGR_ERROR_NONE; +} diff --git a/src/lib/interface/UiIfaceView.cpp b/src/lib/interface/UiIfaceView.cpp index f4efd15..947edd5 100644 --- a/src/lib/interface/UiIfaceView.cpp +++ b/src/lib/interface/UiIfaceView.cpp @@ -150,7 +150,7 @@ UiIfaceViewImpl::~UiIfaceViewImpl() if ((view_count > 1) && (this->_viewmgr->getLastView() == this->_view)) { auto pview = this->_viewmgr->getView(view_count - 2); - pview->onLoad(); + if (!pview->getContent()) pview->onLoad(); this->_viewmgr->popViewFinished(pview); activateTopView = true; } diff --git a/src/lib/interface/UiIfaceViewmgr.cpp b/src/lib/interface/UiIfaceViewmgr.cpp index 563acf5..1e813f9 100644 --- a/src/lib/interface/UiIfaceViewmgr.cpp +++ b/src/lib/interface/UiIfaceViewmgr.cpp @@ -248,8 +248,7 @@ int UiIfaceViewmgrImpl::pushView(UiIfaceView *view) //If view manager is not activated yet, don't load view. if (!this->isActivated()) return UI_VIEWMGR_ERROR_NONE; - view->onLoad(); - view->onDeactivate(); + if (!view->getContent()) view->onLoad(); if (this->_viewList.size() != 1) { this->setEventBlock(view, true); @@ -294,7 +293,7 @@ int UiIfaceViewmgrImpl::popView() auto nx = prev(this->_viewList.end(), 2); auto pview = *nx; pview->_setPopping(true); - pview->onLoad(); + if (!pview->getContent()) pview->onLoad(); pview->onDeactivate(); this->setEventBlock(pview, true); @@ -393,8 +392,7 @@ int UiIfaceViewmgrImpl::activate() auto view = this->getLastView(); - view->onLoad(); - view->onDeactivate(); + if (!view->getContent()) view->onLoad(); view->onActivate(); this->_inst->activateTopView(); -- 2.34.1