From 7c018117c44fbddddade6a39598cb66135101de2 Mon Sep 17 00:00:00 2001 From: HeeJu Kang Date: Wed, 3 Jul 2013 20:24:58 +0900 Subject: [PATCH] Fix b/s Change-Id: I93e6d22906e9c4960e9150104ef4ad6b2fb5a02d Signed-off-by: HeeJu Kang --- src/FShell_AppWidgetViewManager.cpp | 63 ++++++++++++++++++++++++++++--------- src/FShell_AppWidgetViewManager.h | 17 ++++++++++ 2 files changed, 66 insertions(+), 14 deletions(-) diff --git a/src/FShell_AppWidgetViewManager.cpp b/src/FShell_AppWidgetViewManager.cpp index a6673d2..e61078b 100644 --- a/src/FShell_AppWidgetViewManager.cpp +++ b/src/FShell_AppWidgetViewManager.cpp @@ -102,6 +102,29 @@ _AppWidgetViewManager::GetInstance(void) return &instance; } +void +_AppWidgetViewManager::Release(void) +{ + _ControlManager* pControlManager = _ControlManager::GetInstance(); + if (pControlManager && __pFrameEventListener) + { + _Window* pWindow = pControlManager->GetCurrentFrame(); + if (pWindow) + { + _Frame* pFrame = dynamic_cast<_Frame*>(pWindow); + if (pFrame) + { + pFrame->RemoveFrameEventListener(*__pFrameEventListener); + } + } + } + + if (__pControlManagerEventListener) + { + pControlManager->RemoveControlManagerEventListener(*__pControlManagerEventListener); + } +} + livebox* _AppWidgetViewManager::AddAppWidgetView(_AppWidgetView* pAppWidgetView, const String& userInfo) { @@ -198,7 +221,10 @@ _AppWidgetViewManager::AddFrameEventListener(void) unique_ptr<_FrameEventListener> pFrameEventListener(new (std::nothrow) _FrameEventListener()); SysTryReturnVoidResult(NID_SHELL, pFrameEventListener, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); - _Window* pWindow = _ControlManager::GetInstance()->GetCurrentFrame(); + _ControlManager* pControlManager = _ControlManager::GetInstance(); + SysTryReturnVoidResult(NID_SHELL, pControlManager, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + _Window* pWindow = pControlManager->GetCurrentFrame(); SysTryReturnVoidResult(NID_SHELL, pWindow, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); __pFrameEventListener = move(pFrameEventListener); @@ -211,6 +237,11 @@ _AppWidgetViewManager::AddFrameEventListener(void) int ret = livebox_client_resumed(); SysLog(NID_SHELL, "ret (%d)", ret); + + __pControlManagerEventListener.reset(new (std::nothrow) _ControlManagerEventListener(this)); + SysTryReturnVoidResult(NID_SHELL, __pControlManagerEventListener, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + + pControlManager->AddControlManagerEventListener(*__pControlManagerEventListener); } } @@ -269,19 +300,6 @@ _AppWidgetViewManager::_AppWidgetViewManager(void) _AppWidgetViewManager::~_AppWidgetViewManager(void) { - _ControlManager* pControlManager = _ControlManager::GetInstance(); - if (pControlManager && __pFrameEventListener) - { - _Window* pWindow = pControlManager->GetCurrentFrame(); - if (pWindow) - { - _Frame* pFrame = dynamic_cast<_Frame*>(pWindow); - if (pFrame) - { - pFrame->RemoveFrameEventListener(*__pFrameEventListener); - } - } - } } MediaPixelFormat @@ -687,6 +705,23 @@ _AppWidgetViewManager::OnAppWidgetResized(livebox* pAppWidget, int ret, void* pD // pAppWidgetViewManager->OnAppWidgetUpdated(pAppWidget); } +_AppWidgetViewManager::_ControlManagerEventListener::_ControlManagerEventListener(_AppWidgetViewManager* pAppWidgetViewManager) + : __pAppWidgetViewManager(pAppWidgetViewManager) +{ +} + +_AppWidgetViewManager::_ControlManagerEventListener::~_ControlManagerEventListener(void) +{ +} + +void +_AppWidgetViewManager::_ControlManagerEventListener::OnControlManagerTerminating(void) +{ + SysLog(NID_SHELL, "ENTER."); + + __pAppWidgetViewManager->Release(); +} + void _AppWidgetViewManager::_FrameEventListener::OnFrameActivated(const Tizen::Ui::Controls::_Frame& source) { diff --git a/src/FShell_AppWidgetViewManager.h b/src/FShell_AppWidgetViewManager.h index 1d4267e..42628b0 100644 --- a/src/FShell_AppWidgetViewManager.h +++ b/src/FShell_AppWidgetViewManager.h @@ -25,6 +25,8 @@ #include #include #include +#include +#include struct livebox; @@ -59,6 +61,7 @@ class _AppWidgetViewManager { public: static _AppWidgetViewManager* GetInstance(void); + void Release(void); livebox* AddAppWidgetView(_AppWidgetView* pAppWidgetView, const Tizen::Base::String& userInfo); void RemoveAppWidgetView(_AppWidgetView* pAppWidgetView); _AppWidgetView* GetAppWidgetView(livebox* pAppWidget) const; @@ -94,6 +97,19 @@ private: static void OnAppWidgetDeleted(livebox *pAppWidget, int ret, void* pData); static void OnAppWidgetResized(livebox* pAppWidget, int ret, void* pData); + class _ControlManagerEventListener + : public Tizen::Ui::_IControlManagerEventListener + { + public: + _ControlManagerEventListener(_AppWidgetViewManager* pAppWidgetViewManager); + virtual ~_ControlManagerEventListener(void); + private: + virtual void OnControlManagerTerminating(void); + + private: + _AppWidgetViewManager* __pAppWidgetViewManager; + }; + class _FrameEventListener : public Tizen::Ui::Controls::_IFrameEventListener { @@ -130,6 +146,7 @@ private: std::unique_ptr __eventHandler; std::unique_ptr __faultEventHandler; std::unique_ptr<_FrameEventListener> __pFrameEventListener; + std::unique_ptr<_ControlManagerEventListener> __pControlManagerEventListener; bool __glMode; std::unique_ptr<_AppWidgetBuffer> __pAppWidgetBuffer; }; -- 2.7.4