From 24b1279856923ceed2c6c1afe9603461a5133e9c Mon Sep 17 00:00:00 2001 From: Hermet Park Date: Wed, 12 Oct 2016 16:43:01 +0900 Subject: [PATCH] fix wrong behavior of insert_view_before/after() APIs. Previously, the apis won't have considered considerably. It's implmeneted better. Change-Id: I885870a52d53417445a93a9bbc7e4f47afe47827 --- src/include/interface/UiIfaceView.h | 2 ++ src/lib/efl/mobile/c/ui_viewmgr.cpp | 8 ++++---- src/lib/interface/UiIfaceView.cpp | 24 +++++++++++++++++++++++- src/lib/interface/UiIfaceViewmgr.cpp | 3 +++ 4 files changed, 32 insertions(+), 5 deletions(-) diff --git a/src/include/interface/UiIfaceView.h b/src/include/interface/UiIfaceView.h index d6d3e26..48f1578 100644 --- a/src/include/interface/UiIfaceView.h +++ b/src/include/interface/UiIfaceView.h @@ -323,6 +323,8 @@ private: */ void _setViewmgr(UiIfaceViewmgr *viewmgr); + void setPopping(bool popping); + /** * @brief Return the viewmgr instance. * diff --git a/src/lib/efl/mobile/c/ui_viewmgr.cpp b/src/lib/efl/mobile/c/ui_viewmgr.cpp index bda2b55..a720596 100644 --- a/src/lib/efl/mobile/c/ui_viewmgr.cpp +++ b/src/lib/efl/mobile/c/ui_viewmgr.cpp @@ -14,9 +14,9 @@ EAPI int ui_viewmgr_push_view(ui_view *view) EAPI int ui_viewmgr_insert_view_before(ui_view *view, ui_view *before) { - if (!before || !view) + if (!view) { - LOGE("Invalid Parameter view = %p, before = %p", view, before); + LOGE("Invalid Parameter view = %p", view); return TIZEN_ERROR_INVALID_PARAMETER; } @@ -25,9 +25,9 @@ EAPI int ui_viewmgr_insert_view_before(ui_view *view, ui_view *before) EAPI int ui_viewmgr_insert_view_after(ui_view *view, ui_view *after) { - if (!after || !view) + if (!view) { - LOGE("Invalid Parameter view = %p, after = %p", view, after); + LOGE("Invalid Parameter view = %p", view); return TIZEN_ERROR_INVALID_PARAMETER; } diff --git a/src/lib/interface/UiIfaceView.cpp b/src/lib/interface/UiIfaceView.cpp index ab49abd..e50fb64 100644 --- a/src/lib/interface/UiIfaceView.cpp +++ b/src/lib/interface/UiIfaceView.cpp @@ -45,6 +45,7 @@ private: unsigned int _rotationCount = 0; ///< The number of available rotations. bool _eventBlock = false; ///< State of event block. bool _removableContent = true; ///< When this value is true, view removes it's content internally on unload state. + bool _popping = false; public: int setEventBlock(bool block); @@ -137,8 +138,24 @@ UiIfaceViewImpl::UiIfaceViewImpl(UiIfaceView *view, const char *name) UiIfaceViewImpl::~UiIfaceViewImpl() { - this->_viewmgr->removeView(this->_view); + //This view is destroyed instantly. + if (this->_viewmgr && !this->_popping) + { + //Activate the previous view in this case. + unsigned int view_count = this->_viewmgr->getViewCount(); + + if ((view_count > 1) && (this->_viewmgr->getLastView() == this->_view)) + { + auto pview = this->_viewmgr->getView(view_count - 2); + this->_viewmgr->popViewFinished(pview); + } + + this->onUnload(); + this->onDestroy(); + } + + if (this->_viewmgr) this->_viewmgr->removeView(this->_view); if (this->_rotations) delete[](this->_rotations); } @@ -416,3 +433,8 @@ void UiIfaceView::onRegionChanged(const char *region) void UiIfaceView::onLanguageChanged(const char *language) { } + +void UiIfaceView::setPopping(bool popping) +{ + this->_impl->_popping = popping; +} diff --git a/src/lib/interface/UiIfaceViewmgr.cpp b/src/lib/interface/UiIfaceViewmgr.cpp index 75e4fbb..aa98fa8 100644 --- a/src/lib/interface/UiIfaceViewmgr.cpp +++ b/src/lib/interface/UiIfaceViewmgr.cpp @@ -188,6 +188,7 @@ void UiIfaceViewmgrImpl::popViewFinished(UiIfaceView *view) //The previous view has been popped. It should become activate. view->onActivate(); this->setEventBlock(view, false); + view->setPopping(false); } UiIfaceViewmgrImpl::UiIfaceViewmgrImpl(UiIfaceViewmgr* viewmgr) @@ -283,6 +284,7 @@ int UiIfaceViewmgrImpl::popView() return TIZEN_ERROR_NONE; } + view->setPopping(true); view->onDeactivate(); this->setEventBlock(view, true); @@ -291,6 +293,7 @@ int UiIfaceViewmgrImpl::popView() //previous page is to be an active page. auto nx = prev(this->_viewList.end(), 2); auto pview = *nx; + pview->setPopping(true); pview->onLoad(); pview->onDeactivate(); this->setEventBlock(pview, true); -- 2.34.1