From: SeungWon Lee Date: Thu, 28 Mar 2013 13:42:44 +0000 (+0900) Subject: Add logic for prevent duplicated form id using on Form based Scene registrations... X-Git-Tag: accepted/tizen_2.1/20130425.033138~631^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=be47bf7307324b9083a0547e79f4358e22c0e7bf;p=framework%2Fosp%2Fuifw.git Add logic for prevent duplicated form id using on Form based Scene registrations. Fix bad exception code return. Change-Id: Id003e9c69889a823601b781af84205add7dcb0e2 Signed-off-by: SeungWon Lee --- diff --git a/src/ui/scenes/FUiScenes_SceneManagerImpl.cpp b/src/ui/scenes/FUiScenes_SceneManagerImpl.cpp index c580305..801d9f6 100644 --- a/src/ui/scenes/FUiScenes_SceneManagerImpl.cpp +++ b/src/ui/scenes/FUiScenes_SceneManagerImpl.cpp @@ -169,6 +169,8 @@ _SceneManagerImpl::Construct(void) SysTryReturn(NID_UI_SCENES, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r)); r = __transitionMap.Construct(0, 0, sceneHashCodeProvider, strComparer); SysTryReturn(NID_UI_SCENES, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r)); + r = __formIdMap.Construct(0, 0, sceneHashCodeProvider, strComparer); + SysTryReturn(NID_UI_SCENES, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r)); r = __sceneControlEvent.Construct(); SysTryReturn(NID_UI_SCENES, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r)); @@ -221,6 +223,24 @@ _SceneManagerImpl::RegisterScene(const SceneId& sceneId, const String& formId, c SysTryReturn(NID_UI_SCENES, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r)); SysTryReturnResult(NID_UI_SCENES, !isContains, E_OBJ_ALREADY_EXIST, "Specified sceneId already exist."); + __formIdMap.ContainsKey(formId, isContains); + if (panelId.IsEmpty()) + { + SysTryReturnResult(NID_UI_SCENES, !isContains, E_INVALID_ARG, "Specified formId already exist. Only 'PanelScene' can share a formId for use as base form."); + } + + if (!isContains) + { + __formIdMap.Add(formId, 1); + } + else + { + int refCount = 0; + __formIdMap.GetValue(formId, refCount); + ++refCount; + __formIdMap.SetValue(formId, refCount); + } + pSceneDescription = new (std::nothrow) _SceneDescription(formId, panelId); SysTryReturnResult(NID_UI_SCENES, pSceneDescription != null, E_OUT_OF_MEMORY, "Memory allocation failed."); @@ -344,6 +364,27 @@ _SceneManagerImpl::UnregisterScene(const SceneId& sceneId) r = __sceneMap.GetValue(sceneId, pSceneDescription); SysTryReturn(NID_UI_SCENES, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r)); + // Remove FormId from __formIdMap + if (pSceneDescription) + { + bool isContains = false; + __formIdMap.ContainsKey(pSceneDescription->formId, isContains); + if (isContains) + { + int refCount = 0; + __formIdMap.GetValue(pSceneDescription->formId, refCount); + --refCount; + if (refCount <= 0) + { + __formIdMap.Remove(pSceneDescription->formId); + } + else + { + __formIdMap.SetValue(pSceneDescription->formId, refCount); + } + } + } + r = __sceneMap.Remove(sceneId); SysTryReturn(NID_UI_SCENES, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r)); @@ -459,13 +500,11 @@ _SceneManagerImpl::GoForward(const ForwardSceneTransition& sceneTransition, cons SysTryReturnResult(NID_UI_SCENES, !__sceneTransitionProgressing, E_IN_PROGRESS, "Previous operation in progressing"); result r = __sceneTransitionMutex.TryToAcquire(); - SysLog(NID_UI_SCENES, "TryToAcquire result= %s", GetErrorMessage(r)); SysTryReturnResult(NID_UI_SCENES, r != E_OBJECT_LOCKED, E_IN_PROGRESS, "Previous operation in progressing"); SysTryReturnResult(NID_UI_SCENES, r != E_SYSTEM, E_SYSTEM, "A system error has been occurred."); r = __sceneTransitionMutex.Acquire(); SysTryReturnResult(NID_UI_SCENES, !IsFailed(r), E_SYSTEM, "A system error has been occurred. Mutex acquire failed."); __sceneTransitionProgressing = true; //## Temporary - SysLog(NID_UI_SCENES, "##### Mutex acquired."); SceneId sceneId; _SceneTransitionImpl forwardSceneTransition; @@ -525,7 +564,6 @@ CATCH: __sceneTransitionProgressing = false; //## Temporary SysTryReturnResult(NID_UI_SCENES, !IsFailed(__sceneTransitionMutex.Release()), E_SYSTEM, "A system error has been occurred. Mutext release failed."); - SysLog(NID_UI_SCENES, "##### Mutex released."); return r; } @@ -535,7 +573,7 @@ _SceneManagerImpl::GoForward(const SceneTransitionId& transitionId, const Tizen: ForwardSceneTransition forwardTransition; result r = GetSceneTransition(transitionId, forwardTransition); - SysTryReturn(NID_UI_SCENES, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r)); + SysTryReturnResult(NID_UI_SCENES, !IsFailed(r), E_INVALID_ARG, "Cannot get transition from Id."); return GoForward(forwardTransition, pArgs); } @@ -802,13 +840,12 @@ _SceneManagerImpl::AddToSceneHistory(const SceneId& sceneId) IListT* _SceneManagerImpl::GetSceneHistoryN(void) const { - IListT* pSceneList = null; - pSceneList = new (std::nothrow) ArrayListT; + std::unique_ptr > pSceneList(new (std::nothrow) ArrayListT); SysTryReturn(NID_UI_SCENES, pSceneList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); pSceneList->AddItems(__sceneHistory); - return pSceneList; + return pSceneList.release(); } _SceneManagerImpl* diff --git a/src/ui/scenes/FUiScenes_SceneManagerImpl.h b/src/ui/scenes/FUiScenes_SceneManagerImpl.h index 7013398..c2acc9d 100644 --- a/src/ui/scenes/FUiScenes_SceneManagerImpl.h +++ b/src/ui/scenes/FUiScenes_SceneManagerImpl.h @@ -202,6 +202,7 @@ private: }; Tizen::Base::Collection::HashMapT __sceneMap; Tizen::Base::Collection::HashMapT __transitionMap; + Tizen::Base::Collection::HashMapT __formIdMap; _SceneControlEvent __sceneControlEvent; SceneId __destroyReservedScene;