Use parameter to DeleteAll instead of separate function

This commit is contained in:
Christian Semmler 2023-12-09 12:05:47 -05:00
parent c9ac6e6a02
commit 78e8284466
2 changed files with 5 additions and 23 deletions

View File

@ -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();

View File

@ -60,8 +60,7 @@ class MxList : protected MxCollection<T> {
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<T>::~MxList()
}
template <class T>
inline void MxList<T>::DeleteAll()
inline void MxList<T>::DeleteAll(MxBool p_destroy)
{
for (MxListEntry<T>* t = m_first;;) {
if (!t)
break;
MxListEntry<T>* 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 <class T>
inline void MxList<T>::ClearAll()
{
for (MxListEntry<T>* t = m_first;;) {
if (!t)
break;
MxListEntry<T>* next = t->GetNext();
delete t;
t = next;
}