From 1e8905baee75873744a952368f4dbd7f724c325a Mon Sep 17 00:00:00 2001 From: "jaewon7.cho" Date: Thu, 21 Mar 2013 14:26:13 +0900 Subject: [PATCH] Change deleting order of Controls Change-Id: I334c2151d251a24d8831ccd2e10bfbe7f5904a2b Signed-off-by: jaewon7.cho --- src/ui/FUi_ContainerImpl.cpp | 54 ++++++++++++++++++++++++++++++++++++++++-- src/ui/FUi_WindowImpl.cpp | 6 ++++- src/ui/inc/FUi_ContainerImpl.h | 1 + 3 files changed, 58 insertions(+), 3 deletions(-) diff --git a/src/ui/FUi_ContainerImpl.cpp b/src/ui/FUi_ContainerImpl.cpp index b4c13a0..ba60f00 100644 --- a/src/ui/FUi_ContainerImpl.cpp +++ b/src/ui/FUi_ContainerImpl.cpp @@ -246,6 +246,54 @@ _ContainerImpl::RemoveChild(int index) } void +_ContainerImpl::DeleteAllChildren(_ContainerImpl* pChild, bool detachSystemChild) +{ + ArrayList* pList = static_cast (pChild->GetChildrenPublic()); + int count = pList->GetCount(); + for (int index = 0; index < count; index++) + { + Container* pContainer = dynamic_cast (pList->GetAt(index)); + result r = GetLastResult(); + if (IsFailed(r)) + { + SysAssert(r == E_OUT_OF_RANGE); + SysLogException(NID_UI, + E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The specified index is out of range (index = %d, count = %d.)", + index, GetChildCount()); + return; + } + + if (pContainer) + { + _ContainerImpl* pContainerImpl = _ContainerImpl::GetInstance(*pContainer); + DeleteAllChildren(pContainerImpl, detachSystemChild); + pContainer->Destroy(); + } + else + { + Control* pControl = static_cast (pList->GetAt(index)); + result r = GetLastResult(); + if (IsFailed(r)) + { + SysAssert(r == E_OUT_OF_RANGE); + SysLogException(NID_UI, + E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The specified index is out of range (index = %d, count = %d.)", + index, GetChildCount()); + return; + } + _ControlImpl* pControlImpl = _ControlImpl::GetInstance(*pControl); + if (pControlImpl) + { + if (detachSystemChild || pControlImpl->GetCore().GetArea() != _CONTROL_AREA_SYSTEM) + { + pControl->Destroy(); + } + } + } + } +} + +void _ContainerImpl::RemoveAllChildren(bool detachSystemChild) { ClearLastResult(); @@ -253,10 +301,11 @@ _ContainerImpl::RemoveAllChildren(bool detachSystemChild) GetCore().DetachAllChildren(detachSystemChild); SysAssert(GetLastResult() == E_SUCCESS); + DeleteAllChildren(this, detachSystemChild); if (detachSystemChild) { - __controlPublics.RemoveAll(true); + __controlPublics.RemoveAll(false); } else { @@ -272,10 +321,11 @@ _ContainerImpl::RemoveAllChildren(bool detachSystemChild) continue; } - r = __controlPublics.Remove(pControl->GetPublic(), true); + r = __controlPublics.Remove(pControl->GetPublic(), false); SysAssert(r == E_SUCCESS); } } + } result diff --git a/src/ui/FUi_WindowImpl.cpp b/src/ui/FUi_WindowImpl.cpp index 0f2a50b..6f69795 100644 --- a/src/ui/FUi_WindowImpl.cpp +++ b/src/ui/FUi_WindowImpl.cpp @@ -383,7 +383,11 @@ _WindowImpl::Destroy(void) _ControlImpl* pImpl = _ControlImpl::GetInstance(*pOwner); pImpl->GetCore().DetachOwnee(GetCore()); } - + else + { + GetCore().GetControlDelegate().OnDetachingFromMainTree(); + } + RemoveAllChildren(true); delete &GetPublic(); return r; } diff --git a/src/ui/inc/FUi_ContainerImpl.h b/src/ui/inc/FUi_ContainerImpl.h index fb82ca1..28d04dc 100644 --- a/src/ui/inc/FUi_ContainerImpl.h +++ b/src/ui/inc/FUi_ContainerImpl.h @@ -53,6 +53,7 @@ public: result AddChild(_ControlImpl* pChild, bool transferOwnership = true); result RemoveChild(_ControlImpl* pChild, bool deallocate = true); result RemoveChild(int index); + void DeleteAllChildren(_ContainerImpl* pChild, bool detachSystemChild = true); void RemoveAllChildren(bool detachSystemChild = true); result MoveChildToTop(const _ControlImpl& child); result MoveChildBefore(const _ControlImpl& targetChild, const _ControlImpl& child); -- 2.7.4