fix a page deletion issue. 44/98244/6
authorHermet Park <hermet@hermet.pe.kr>
Wed, 16 Nov 2016 13:50:33 +0000 (22:50 +0900)
committerHermet Park <chuneon.park@samsung.com>
Thu, 17 Nov 2016 07:12:12 +0000 (23:12 -0800)
If user deletes a page instantly(ie, delete(view); ), the previous page won't be visible.
Actually viewmgr didn't care the scenario and this fixes the siutation.

Change-Id: Ibbbc8c02505340aae095402db4e336027b5cf9da

src/examples/efl/cpp/page2.h
src/include/efl/UiBaseViewmgr.h
src/include/interface/UiIfaceViewmgr.h
src/lib/efl/UiBaseViewmgr.cpp
src/lib/efl/mobile/UiStandardView.cpp
src/lib/interface/UiIfaceView.cpp
src/lib/interface/UiIfaceViewmgr.cpp

index c5055b91b1093557b1306bf682523baa781da5f0..1e114d769f7c97eed8cc7f21d77f905ac13c58d6 100644 (file)
@@ -35,7 +35,7 @@ protected:
                                                                        //Next Button Callback
                                                                        [](void *data, Eo *obj, void *event_info)
                                                                        {
-                                                                         UI_VIEWMGR->pushView(new page3());
+                                                                               UI_VIEWMGR->pushView(new page3());
                                                                        });
 
                //Title left button
index dc340582b6a290b8900f3f100ec75c3ffd9af7c8..95b6e16140977872a33e0ef9e3c93b05570c930a 100644 (file)
@@ -214,6 +214,17 @@ protected:
         */
        void setIndicator(UiViewIndicator indicator);
 
+       /**
+        *  @brief Prepare the top view to be shown instantly.
+        *
+        *  @remark This interface may called when top view should be prepared. If the current visible view is removed unexpectedly, the view manager requests
+        *          the next top view by calling this interface(except push, pop, insert).
+        *
+        *  @return @c 0 on success, otherwise a negative error value.
+        *  @retval #UI_VIEWMGR_ERROR_NONE Successful
+        */
+       int activateTopView() override;
+
        /**
         *  @brief This is a constructor for initializing viewmgr.
         *
index 7f6e72942e3ef32e0847c66453986af06ad5bed5..ec6e0441354f80c493ae131fb99a314b4200a788 100644 (file)
@@ -131,7 +131,7 @@ protected:
         *
         *  @warning This function must be called when push transition is finished.
         */
-       void popViewFinished(UiIfaceView *view);
+       virtual void popViewFinished(UiIfaceView *view);
 
        /**
         *  @brief Push a new view into this viewmgr. This function is used for when application switches a current view to a new one.
@@ -273,6 +273,17 @@ protected:
         */
        UiIfaceView *getLastView();
 
+       /**
+        *  @brief Prepare the top view to be shown instantly.
+        *
+        *  @remark This interface may called when top view should be prepared. If the current visible view is removed unexpectedly, the view manager requests
+        *          the next top view by calling this interface(except push, pop, insert).
+        *
+        *  @return @c 0 on success, otherwise a negative error value.
+        *  @retval #UI_VIEWMGR_ERROR_NONE Successful
+        */
+       virtual int activateTopView() = 0;
+
        ///Constructor.
        UiIfaceViewmgr();
 
index 34dcdea1fd219645c075a5139823d60ac9675917..797f11d8466c1a751816146870f268bc145629c1 100644 (file)
@@ -50,7 +50,6 @@ private:
        bool _createBaseLayout(Elm_Scroller *scroller, const char *style);
        void _setIndicator(UiViewIndicator indicator) noexcept;
        void _setAvailableRotations(UiBaseView *view) noexcept;
-       void _activateTopView();
        bool _init();
        bool _term();
 
@@ -62,6 +61,7 @@ public:
        void deactivate() noexcept;
        void pushView(UiBaseView *view);
        void popView();
+       int activateTopView() noexcept;
 
        Eo *getBase() const {
                return this->_layout;
@@ -156,7 +156,7 @@ Elm_Layout *UiBaseViewmgrImpl::_setTransitionLayout(string transitionStyle)
        return this->_layout;
 }
 
-void UiBaseViewmgrImpl::_activateTopView()
+int UiBaseViewmgrImpl::activateTopView() noexcept
 {
        Eo *pcontent = elm_object_part_content_unset(this->getBase(), "content");
        if (pcontent) evas_object_hide(pcontent);
@@ -175,6 +175,8 @@ void UiBaseViewmgrImpl::_activateTopView()
 
        this->_setAvailableRotations(view);
        this->_setIndicator(view->getIndicator());
+
+       return UI_VIEWMGR_ERROR_NONE;
 }
 
 //FIXME: How to deal with indicator in other UI framework? Dali? Volt?
@@ -342,7 +344,6 @@ bool UiBaseViewmgrImpl::_term()
 
 void UiBaseViewmgrImpl::activate() noexcept
 {
-       this->_activateTopView();
        evas_object_show(this->_win);
 }
 
@@ -365,7 +366,7 @@ void UiBaseViewmgrImpl::popView()
        if (!strcmp(view->getTransitionStyle(), "none")) {
                this->_viewmgr->popViewFinished(pview);
                this->_viewmgr->popViewFinished(view);
-               this->_activateTopView();
+               this->activateTopView();
                return;
        }
 
@@ -375,7 +376,7 @@ void UiBaseViewmgrImpl::popView()
                LOGE("invalid effect transition style?! = %s", view->getTransitionStyle());
                this->_viewmgr->popViewFinished(pview);
                this->_viewmgr->popViewFinished(view);
-               this->_activateTopView();
+               this->activateTopView();
                return;
        }
 
@@ -398,8 +399,8 @@ void UiBaseViewmgrImpl::pushView(UiBaseView *view)
 
        //In case, if viewmgr has one view, we skip effect.
        if (this->_viewmgr->getViewCount() == 1) {
-               this->_activateTopView();
                this->_viewmgr->pushViewFinished(view);
+               this->activateTopView();
                return;
        }
 
@@ -407,9 +408,9 @@ void UiBaseViewmgrImpl::pushView(UiBaseView *view)
 
        //In case, if view doesn't have transition effect
        if (!strcmp(view->getTransitionStyle(), "none")) {
-               this->_activateTopView();
                this->_viewmgr->pushViewFinished(pview);
                this->_viewmgr->pushViewFinished(view);
+               this->activateTopView();
                return;
        }
 
@@ -417,9 +418,9 @@ void UiBaseViewmgrImpl::pushView(UiBaseView *view)
        Elm_Layout *effect = this->_setTransitionLayout(view->getTransitionStyle());
        if (!effect) {
                LOGE("invalid effect transition style?! = %s", view->getTransitionStyle());
-               this->_activateTopView();
                this->_viewmgr->pushViewFinished(pview);
                this->_viewmgr->pushViewFinished(view);
+               this->activateTopView();
                return;
        }
 
@@ -543,3 +544,8 @@ void UiBaseViewmgr::setIndicator(UiViewIndicator indicator)
 {
        this->_impl->_setIndicator(indicator);
 }
+
+int UiBaseViewmgr::activateTopView()
+{
+       this->_impl->activateTopView();
+}
index 580900044b0d155e18277308f98bb450cc925987..b94baa31f2360794a42f089f0f3dfffb8b814603 100644 (file)
@@ -106,6 +106,20 @@ bool UiStandardViewImpl::_destroyLayout() noexcept
 {
        if (!this->_layout) return false;
 
+       //clean up sub contents in advance
+       if (this->_titleLeftBtn) {
+               evas_object_event_callback_del(this->_titleLeftBtn, EVAS_CALLBACK_DEL, _titleLeftBtnDelCb);
+               this->_titleLeftBtn  = nullptr;
+       }
+       if (this->_titleRightBtn) {
+               evas_object_event_callback_del(this->_titleRightBtn, EVAS_CALLBACK_DEL, _titleRightBtnDelCb);
+               this->_titleRightBtn  = nullptr;
+       }
+       if (this->_toolbar) {
+               evas_object_event_callback_del(this->_toolbar, EVAS_CALLBACK_DEL, _toolbarDelCb);
+               this->_toolbar = nullptr;
+       }
+
        evas_object_del(this->_layout);
        this->_layout = nullptr;
 
index 6788fb75f30f8c27016147423dc949a44223c55d..f4efd152277adf9f9d103118e03ce7a0ec7be7a0 100644 (file)
@@ -139,6 +139,7 @@ UiIfaceViewImpl::UiIfaceViewImpl(UiIfaceView *view, const char *name)
 
 UiIfaceViewImpl::~UiIfaceViewImpl()
 {
+       bool activateTopView = false; //If this view is deleted instantly.
 
        //This view is destroyed instantly.
        if (this->_viewmgr && !this->_popping)
@@ -149,14 +150,21 @@ UiIfaceViewImpl::~UiIfaceViewImpl()
                if ((view_count > 1) && (this->_viewmgr->getLastView() == this->_view))
                {
                        auto pview = this->_viewmgr->getView(view_count - 2);
+                       pview->onLoad();
                        this->_viewmgr->popViewFinished(pview);
+                       activateTopView = true;
                }
 
                this->onUnload();
                this->onDestroy();
        }
 
-       if (this->_viewmgr) this->_viewmgr->removeView(this->_view);
+       if (this->_viewmgr) {
+               auto* viewmgr = this->_viewmgr;
+               this->_viewmgr->removeView(this->_view);
+               if (activateTopView) viewmgr->activateTopView();
+       }
+
        if (this->_rotations) delete[](this->_rotations);
 }
 
index 0370cc937a3292b83c24f08de2b1935a57debba1..563acf535f320f1e2dc30f8b74d8204b44acc9ab 100644 (file)
@@ -397,6 +397,8 @@ int UiIfaceViewmgrImpl::activate()
        view->onDeactivate();
        view->onActivate();
 
+       this->_inst->activateTopView();
+
        return UI_VIEWMGR_ERROR_NONE;
 }