Fix the insertViewAfter() wrong behaviors. 70/101170/2
authorHermet Park <hermet@hermet.pe.kr>
Wed, 30 Nov 2016 10:22:57 +0000 (19:22 +0900)
committerHermet Park <chuneon.park@samsung.com>
Wed, 30 Nov 2016 13:07:35 +0000 (05:07 -0800)
I missed the UiBaseViewmgr hasn't overridden the pushView() method
that violates the UiIfaceViewmgr insertViewAfter() expectation.
insertViewAfter() API internally calls Viewmgr's pushView() logically.
This designed to lead to UiBaseViewmgr 's pushView() in the end.

But It won't be happened because UiBaseViewmgr didn't override pushView().

Changed to override the UiIfaceViewmgr PushView() so that
PushView() of the UiBaseViewmgr can be triggered by UiIfaceViewmgr properly.

Change-Id: I45548a725a3b58b1e456e17a130927a15489e069

src/include/efl/UiBaseViewmgr.h
src/include/interface/UiIfaceViewmgr.h
src/lib/efl/UiBaseViewmgr.cpp
src/lib/interface/UiIfaceView.cpp
src/lib/interface/UiIfaceViewmgr.cpp

index 95b6e16140977872a33e0ef9e3c93b05570c930a..c594719d9f541ab704da00d6b1d72862ceea32ef 100644 (file)
@@ -86,7 +86,7 @@ public:
         *  @see insertViewAfter()
         *  @see popView()
         */
-       virtual int pushView(UiBaseView *view);
+       virtual int pushView(ui_viewmanager::UiIfaceView *view) override;
 
        /**
         *  @brief Pop the top(last) view from this viewmgr view list.
@@ -106,32 +106,6 @@ public:
         */
        virtual int popView() override;
 
-       /**
-        *  @brief Insert a view in this viewmgr view list. Specifically, insert a given @a view right before of the given view, @before.
-        *
-        *  @param[in] view A view to insert in the viewmgr view list.
-        *  @param[in] before A view that will be just inserted after @a view. If you pass @c nullptr, @a view will be inserted at the front of the view list.
-        *
-        *  @return @c 0 on success, otherwise a negative error value.
-        *  @retval #UI_VIEWMGR_ERROR_NONE Successful
-        *  @retval #UI_VIEWMGR_ERROR_NOT_PERMITTED @a view was already inserted.
-        *  @retval #UI_VIEWMGR_ERROR_INVALID_PARAMETER @a view is not valid.
-        */
-       virtual int insertViewBefore(UiBaseView *view, UiBaseView *before);
-
-       /**
-        *  @brief Insert a view in this viewmgr view list. Specifically, insert a given @a view right after of the given view, @after.
-        *
-        *  @param[in] view A view to insert in the viewmgr view list.
-        *  @param[in] after A view that will be just inserted before the @a view. If you pass @c nullptr, @a view will be inserted at the end of the view list.
-        *
-        *  @return @c 0 on success, otherwise a negative error value.
-        *  @retval #UI_VIEWMGR_ERROR_NONE Successful
-        *  @retval #UI_VIEWMGR_ERROR_NOT_PERMITTED @a view was already inserted.
-        *  @retval #UI_VIEWMGR_ERROR_INVALID_PARAMETER @a view is not valid.
-        */
-       virtual int insertViewAfter(UiBaseView *view, UiBaseView *after);
-
        /**
         *  @brief Return a window object of viewmgr.
         *
index ec6e0441354f80c493ae131fb99a314b4200a788..1d0ec5740b2a65b6d0f4fba2e5a0af66522ba8a7 100644 (file)
@@ -35,6 +35,73 @@ class UiIfaceView;
 class UiIfaceViewmgr
 {
 public:
+       /**
+        *  @brief Push a new view into this viewmgr. This function is used for when application switches a current view to a new one.
+        *
+        *  @note Normally, the current view will be hidden by a new view. In default, when user calls this API, view will be switched to @a view instantly,
+        *        only when viewmgr state is activated. Otherwise, the @a view will be shown later when viewmgr is activated. push_view() is designed for providing
+        *        view transition effect. If you want push view instantly without any transition, you could use insert_view_before() or insert_view_after().
+        *        or use the view transition style function.
+        *        If you want to pop the current view, the please use pop_view().
+        *
+        *  @param[in] view A view to insert at the end of viewmgr view list.
+        *
+        *  @return @c 0 on success, otherwise a negative error value.
+        *  @retval #UI_VIEWMGR_ERROR_INVALID_PARAMETER @a view is not valid.
+        *  @retval #UI_VIEWMGR_ERROR_NOT_PERMITTED @a view was already inserted.
+        *
+        *  @see activated()
+        *  @see insertViewBefore()
+        *  @see insertViewAfter()
+        *  @see popView()
+        *  @see UiIfaceView::setTransitionStyle()
+        */
+       virtual int pushView(UiIfaceView *view);
+
+       /**
+        *  @brief Pop the top(last) view from this viewmgr view list.
+        *         This function is used when application switches the current view back to the previous view.
+        *         The top view will be removed from the view stack and then it will be deleted by the viewmgr.
+        *
+        *  @note If the view is just one left, then viewmgr would be deactivated automatically since the ui application might be invalid anymore. Otherwise,
+        *        the application will be terminated. It's up to system configuration.
+        *
+        *  @return @c 0 on success, otherwise a negative error value.
+        *  @retval #UI_VIEWMGR_ERROR_NONE Successful
+        *  @retval #UI_VIEWMGR_ERROR_NOT_PERMITTED No more views to pop.
+        *  @retval #UI_VIEWMGR_ERROR_ALREADY_IN_PROGRESS On a certain profile, it may not allow to pop multiple views at the same time.
+        *
+        *  @see deactivate()
+        *  @see pushView()
+        */
+       virtual int popView();
+
+       /**
+        *  @brief Insert a view in this viewmgr view list. Specifically, insert a given @a view right before of the given view, @before.
+        *
+        *  @param[in] view A view to insert in the viewmgr view list.
+        *  @param[in] before A view that will be just inserted after @a view. If you pass @c nullptr, @a view will be inserted at the front of the view list.
+        *
+        *  @return @c 0 on success, otherwise a negative error value.
+        *  @retval #UI_VIEWMGR_ERROR_NONE Successful
+        *  @retval #UI_VIEWMGR_ERROR_NOT_PERMITTED @a view was already inserted.
+        *  @retval #UI_VIEWMGR_ERROR_INVALID_PARAMETER @a view is not valid.
+        */
+       int insertViewBefore(UiIfaceView *view, UiIfaceView *before);
+
+       /**
+        *  @brief Insert a view in this viewmgr view list. Specifically, insert a given @a view right after of the given view, @after.
+        *
+        *  @param[in] view A view to insert in the viewmgr view list.
+        *  @param[in] after A view that will be just inserted before the @a view. If you pass @c nullptr, @a view will be inserted at the end of the view list.
+        *
+        *  @return @c 0 on success, otherwise a negative error value.
+        *  @retval #UI_VIEWMGR_ERROR_NONE Successful
+        *  @retval #UI_VIEWMGR_ERROR_NOT_PERMITTED @a view was already inserted.
+        *  @retval #UI_VIEWMGR_ERROR_INVALID_PARAMETER @a view is not valid.
+        */
+       int insertViewAfter(UiIfaceView *view, UiIfaceView *after);
+
        /**
         *  @brief Activate this view manager.
         *
@@ -133,73 +200,6 @@ protected:
         */
        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.
-        *
-        *  @note Normally, the current view will be hidden by a new view. In default, when user calls this API, view will be switched to @a view instantly,
-        *        only when viewmgr state is activated. Otherwise, the @a view will be shown later when viewmgr is activated. push_view() is designed for providing
-        *        view transition effect. If you want push view instantly without any transition, you could use insert_view_before() or insert_view_after().
-        *        or use the view transition style function.
-        *        If you want to pop the current view, the please use pop_view().
-        *
-        *  @param[in] view A view to insert at the end of viewmgr view list.
-        *
-        *  @return @c 0 on success, otherwise a negative error value.
-        *  @retval #UI_VIEWMGR_ERROR_INVALID_PARAMETER @a view is not valid.
-        *  @retval #UI_VIEWMGR_ERROR_NOT_PERMITTED @a view was already inserted.
-        *
-        *  @see activated()
-        *  @see insertViewBefore()
-        *  @see insertViewAfter()
-        *  @see popView()
-        *  @see UiIfaceView::setTransitionStyle()
-        */
-       virtual int pushView(UiIfaceView *view);
-
-       /**
-        *  @brief Pop the top(last) view from this viewmgr view list.
-        *         This function is used when application switches the current view back to the previous view.
-        *         The top view will be removed from the view stack and then it will be deleted by the viewmgr.
-        *
-        *  @note If the view is just one left, then viewmgr would be deactivated automatically since the ui application might be invalid anymore. Otherwise,
-        *        the application will be terminated. It's up to system configuration.
-        *
-        *  @return @c 0 on success, otherwise a negative error value.
-        *  @retval #UI_VIEWMGR_ERROR_NONE Successful
-        *  @retval #UI_VIEWMGR_ERROR_NOT_PERMITTED No more views to pop.
-        *  @retval #UI_VIEWMGR_ERROR_ALREADY_IN_PROGRESS On a certain profile, it may not allow to pop multiple views at the same time.
-        *
-        *  @see deactivate()
-        *  @see pushView()
-        */
-       virtual int popView();
-
-       /**
-        *  @brief Insert a view in this viewmgr view list. Specifically, insert a given @a view right before of the given view, @before.
-        *
-        *  @param[in] view A view to insert in the viewmgr view list.
-        *  @param[in] before A view that will be just inserted after @a view. If you pass @c nullptr, @a view will be inserted at the front of the view list.
-        *
-        *  @return @c 0 on success, otherwise a negative error value.
-        *  @retval #UI_VIEWMGR_ERROR_NONE Successful
-        *  @retval #UI_VIEWMGR_ERROR_NOT_PERMITTED @a view was already inserted.
-        *  @retval #UI_VIEWMGR_ERROR_INVALID_PARAMETER @a view is not valid.
-        */
-       int insertViewBefore(UiIfaceView *view, UiIfaceView *before);
-
-       /**
-        *  @brief Insert a view in this viewmgr view list. Specifically, insert a given @a view right after of the given view, @after.
-        *
-        *  @param[in] view A view to insert in the viewmgr view list.
-        *  @param[in] after A view that will be just inserted before the @a view. If you pass @c nullptr, @a view will be inserted at the end of the view list.
-        *
-        *  @return @c 0 on success, otherwise a negative error value.
-        *  @retval #UI_VIEWMGR_ERROR_NONE Successful
-        *  @retval #UI_VIEWMGR_ERROR_NOT_PERMITTED @a view was already inserted.
-        *  @retval #UI_VIEWMGR_ERROR_INVALID_PARAMETER @a view is not valid.
-        */
-       int insertViewAfter(UiIfaceView *view, UiIfaceView *after);
-
        /**
         *  @brief Remove the given view from this viewmgr view list.
         *
index 754123a033628218e1a2ec4c7086615c5250238f..afb46322b762f036f408714454933c9497a7258b 100644 (file)
@@ -495,26 +495,16 @@ int UiBaseViewmgr::popView()
        return UI_VIEWMGR_ERROR_NONE;
 }
 
-int UiBaseViewmgr::pushView(UiBaseView *view)
+int UiBaseViewmgr::pushView(UiIfaceView *view)
 {
        int ret = UiIfaceViewmgr::pushView(view);
        if (ret != UI_VIEWMGR_ERROR_NONE) return ret;
 
-       this->_impl->pushView(view);
+       this->_impl->pushView(dynamic_cast<UiBaseView*>(view));
 
        return UI_VIEWMGR_ERROR_NONE;
 }
 
-int UiBaseViewmgr::insertViewBefore(UiBaseView *view, UiBaseView *before)
-{
-       return UiIfaceViewmgr::insertViewBefore(view, before);
-}
-
-int UiBaseViewmgr::insertViewAfter(UiBaseView *view, UiBaseView *after)
-{
-       return UiIfaceViewmgr::insertViewAfter(view, after);
-}
-
 UiBaseView *UiBaseViewmgr::getView(unsigned int idx)
 {
        return dynamic_cast<UiBaseView *>(UiIfaceViewmgr::getView(idx));
index 947edd5dd0d4a186e48b83880442279b28383a11..81242726ce159a436d6c8e1d25271e3b81f5b349 100644 (file)
@@ -155,8 +155,9 @@ UiIfaceViewImpl::~UiIfaceViewImpl()
                        activateTopView = true;
                }
 
-               this->onUnload();
-               this->onDestroy();
+               this->_view->onDeactivate();
+               this->_view->onUnload();
+               this->_view->onDestroy();
        }
 
        if (this->_viewmgr) {
index 1e813f93c0d1a0bed14619f0a2edd825042cc3d8..8f69e562bde0535f67797848ea244cf05ed761fa 100644 (file)
@@ -88,7 +88,6 @@ int UiIfaceViewmgrImpl::insertViewAfter(UiIfaceView *view, UiIfaceView *after)
        if (view == after) {
                LOGE("invalid view argument. view == after?");
                return UI_VIEWMGR_ERROR_INVALID_PARAMETER;
-
        }
 
        int ret = this->connectView(view);
@@ -98,22 +97,23 @@ int UiIfaceViewmgrImpl::insertViewAfter(UiIfaceView *view, UiIfaceView *after)
                return ret;
        }
 
-       if (this->_viewList.size() > 0) {
-               for (auto it = this->_viewList.begin(); it != this->_viewList.end(); it++) {
-                       if (after == *it) {
-                               //If the after is a last item of list.
-                               //view has to push now.
-                               if (it == this->_viewList.end())
-                                       this->pushView(view);
-                               else
-                                       this->_viewList.insert(++it, view);
-
+       for (auto it = this->_viewList.begin(); it != this->_viewList.end(); ++it) {
+               if (after == *it) {
+                       //If the after is a last item of list, view has to push now.
+                       auto it2 = it;
+                       if ((++it2) == this->_viewList.end())
+                       {
+                               return this->_inst->pushView(view);
+                       }
+                       else
+                       {
+                               this->_viewList.insert(++it, view);
                                return UI_VIEWMGR_ERROR_NONE;
                        }
                }
        }
 
-       return this->pushView(view);
+       return this->_inst->pushView(view);
 }
 
 bool UiIfaceViewmgrImpl::needSoftKey() noexcept