diff --git a/include/wx/list.h b/include/wx/list.h index a65bb8d485..75c3c01cbb 100644 --- a/include/wx/list.h +++ b/include/wx/list.h @@ -475,8 +475,7 @@ public: wxNode *Add(const char *s) { return (wxNode *)wxStringListBase::Append(copystring(s)); } - void Delete(const char *s) - { wxStringListBase::DeleteObject((char *)s); } + bool Delete(const char *s); char **ListToArray(bool new_copies = FALSE) const; bool Member(const char *s) const; diff --git a/src/common/list.cpp b/src/common/list.cpp index 4eaf11949e..c6e0ebccb9 100644 --- a/src/common/list.cpp +++ b/src/common/list.cpp @@ -397,7 +397,6 @@ bool wxListBase::DeleteObject(void *object) return FALSE; } - void wxListBase::Clear() { wxNodeBase *current = m_nodeFirst; @@ -520,6 +519,23 @@ void wxStringListNode::DeleteData() delete [] (char *)GetData(); } +bool wxStringList::Delete(const char *s) +{ + wxStringListNode *current; + + for ( current = GetFirst(); current; current = current->GetNext() ) + { + if ( strcmp(current->GetData(), s) == 0 ) + { + DeleteNode(current); + return TRUE; + } + } + + // not found + return FALSE; +} + void wxStringList::DoCopy(const wxStringList& other) { wxASSERT( GetCount() == 0 ); // this list must be empty before copying!