diff --git a/LEGO1/mxcompositepresenter.cpp b/LEGO1/mxcompositepresenter.cpp index b327d5d9..d3128c62 100644 --- a/LEGO1/mxcompositepresenter.cpp +++ b/LEGO1/mxcompositepresenter.cpp @@ -98,7 +98,7 @@ void MxCompositePresenter::EndAction() if (!m_action) return; - ((MxDSMultiAction*) m_action)->GetActionList()->ClearAll(); + ((MxDSMultiAction*) m_action)->GetActionList()->DeleteAll(FALSE); while (!m_list.empty()) { MxPresenter* presenter = m_list.front(); diff --git a/LEGO1/mxlist.h b/LEGO1/mxlist.h index 1e06d064..a55aae6e 100644 --- a/LEGO1/mxlist.h +++ b/LEGO1/mxlist.h @@ -60,8 +60,7 @@ class MxList : protected MxCollection { virtual ~MxList() override; void Append(T p_obj) { _InsertEntry(p_obj, this->m_last, NULL); }; - void DeleteAll(); - void ClearAll(); + void DeleteAll(MxBool p_destroy = TRUE); MxU32 GetCount() { return this->m_count; } void SetDestroy(void (*p_customDestructor)(T)) { this->m_customDestructor = p_customDestructor; } @@ -122,34 +121,17 @@ MxList::~MxList() } template -inline void MxList::DeleteAll() +inline void MxList::DeleteAll(MxBool p_destroy) { for (MxListEntry* t = m_first;;) { if (!t) break; MxListEntry* next = t->GetNext(); - this->m_customDestructor(t->GetValue()); - delete t; - t = next; - } - this->m_count = 0; - m_last = NULL; - m_first = NULL; -} + if (p_destroy) + this->m_customDestructor(t->GetValue()); -// TODO: This is DeleteAll without using the customDestructor. -// Were they a single function originally, possibly -// parameterized on "p_ownership"? -template -inline void MxList::ClearAll() -{ - for (MxListEntry* t = m_first;;) { - if (!t) - break; - - MxListEntry* next = t->GetNext(); delete t; t = next; }