diff --git a/include/wx/dataview.h b/include/wx/dataview.h index 304864aab1..a3547fb13c 100644 --- a/include/wx/dataview.h +++ b/include/wx/dataview.h @@ -27,6 +27,7 @@ #include "wx/dataobj.h" #include "wx/withimages.h" #include "wx/systhemectrl.h" +#include "wx/vector.h" class WXDLLIMPEXP_FWD_CORE wxImageList; class wxItemAttr; @@ -179,8 +180,7 @@ private: // wxDataViewModel // --------------------------------------------------------- -WX_DECLARE_LIST_WITH_DECL(wxDataViewModelNotifier, wxDataViewModelNotifiers, - class WXDLLIMPEXP_ADV); +typedef wxVector wxDataViewModelNotifiers; class WXDLLIMPEXP_ADV wxDataViewModel: public wxRefCounter { @@ -273,8 +273,9 @@ public: virtual bool IsVirtualListModel() const { return false; } protected: - // the user should not delete this class directly: he should use DecRef() instead! - virtual ~wxDataViewModel() { } + // Dtor is protected because the objects of this class must not be deleted, + // DecRef() must be used instead. + virtual ~wxDataViewModel(); // Helper function used by the default Compare() implementation to compare // values of types it is not aware about. Can be overridden in the derived @@ -285,7 +286,7 @@ protected: return 0; } - +private: wxDataViewModelNotifiers m_notifiers; }; diff --git a/src/common/datavcmn.cpp b/src/common/datavcmn.cpp index 0f2ccc24b8..117dec03e3 100644 --- a/src/common/datavcmn.cpp +++ b/src/common/datavcmn.cpp @@ -95,9 +95,6 @@ wxFont wxDataViewItemAttr::GetEffectiveFont(const wxFont& font) const // wxDataViewModelNotifier // --------------------------------------------------------- -#include "wx/listimpl.cpp" -WX_DEFINE_LIST(wxDataViewModelNotifiers) - bool wxDataViewModelNotifier::ItemsAdded( const wxDataViewItem &parent, const wxDataViewItemArray &items ) { size_t count = items.GetCount(); @@ -134,7 +131,15 @@ bool wxDataViewModelNotifier::ItemsChanged( const wxDataViewItemArray &items ) wxDataViewModel::wxDataViewModel() { - m_notifiers.DeleteContents( true ); +} + +wxDataViewModel::~wxDataViewModel() +{ + wxDataViewModelNotifiers::const_iterator iter; + for (iter = m_notifiers.begin(); iter != m_notifiers.end(); ++iter) + { + delete *iter; + } } bool wxDataViewModel::ItemAdded( const wxDataViewItem &parent, const wxDataViewItem &item ) @@ -305,7 +310,20 @@ void wxDataViewModel::AddNotifier( wxDataViewModelNotifier *notifier ) void wxDataViewModel::RemoveNotifier( wxDataViewModelNotifier *notifier ) { - m_notifiers.DeleteObject( notifier ); + wxDataViewModelNotifiers::iterator iter; + for (iter = m_notifiers.begin(); iter != m_notifiers.end(); ++iter) + { + if ( *iter == notifier ) + { + delete notifier; + m_notifiers.erase(iter); + + // Skip the assert below. + return; + } + } + + wxFAIL_MSG(wxS("Removing non-registered notifier")); } int wxDataViewModel::Compare( const wxDataViewItem &item1, const wxDataViewItem &item2,