From d76240bfe106c10ca9a775448f712311fc5e1443 Mon Sep 17 00:00:00 2001 From: Mattia Barbon Date: Sun, 2 Feb 2003 21:00:06 +0000 Subject: [PATCH] Fix client data handling: delete client data for all items when a wxChoice is deleted, delete client data for an item when that item is deleted. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@19084 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/mac/carbon/choice.cpp | 12 ++++++++++-- src/mac/carbon/combobox.cpp | 4 ++++ src/mac/choice.cpp | 12 ++++++++++-- src/mac/combobox.cpp | 4 ++++ 4 files changed, 28 insertions(+), 4 deletions(-) diff --git a/src/mac/carbon/choice.cpp b/src/mac/carbon/choice.cpp index 46e08be0d5..ac29f3125b 100644 --- a/src/mac/carbon/choice.cpp +++ b/src/mac/carbon/choice.cpp @@ -21,7 +21,15 @@ IMPLEMENT_DYNAMIC_CLASS(wxChoice, wxControl) extern MenuHandle NewUniqueMenu() ; wxChoice::~wxChoice() { - // DeleteMenu( m_macPopUpMenuId ) ; + if ( HasClientObjectData() ) + { + size_t i, max = GetCount(); + + for ( i = 0; i < max; ++i ) + delete GetClientObject(i); + } + + // DeleteMenu( m_macPopUpMenuId ) ; // DisposeMenu( m_macPopUpMenuHandle ) ; } bool wxChoice::Create(wxWindow *parent, wxWindowID id, @@ -221,4 +229,4 @@ wxSize wxChoice::DoGetBestSize() const } return wxSize(lbWidth, lbHeight); -} \ No newline at end of file +} diff --git a/src/mac/carbon/combobox.cpp b/src/mac/carbon/combobox.cpp index 664d142f40..feee187143 100644 --- a/src/mac/carbon/combobox.cpp +++ b/src/mac/carbon/combobox.cpp @@ -408,6 +408,10 @@ void wxComboBox::Append(const wxString& item) void wxComboBox::Delete(int n) { + if ( HasClientObjectData() ) + { + SetClientObject(n, NULL); + } m_choice->Delete( n ); } diff --git a/src/mac/choice.cpp b/src/mac/choice.cpp index 46e08be0d5..ac29f3125b 100644 --- a/src/mac/choice.cpp +++ b/src/mac/choice.cpp @@ -21,7 +21,15 @@ IMPLEMENT_DYNAMIC_CLASS(wxChoice, wxControl) extern MenuHandle NewUniqueMenu() ; wxChoice::~wxChoice() { - // DeleteMenu( m_macPopUpMenuId ) ; + if ( HasClientObjectData() ) + { + size_t i, max = GetCount(); + + for ( i = 0; i < max; ++i ) + delete GetClientObject(i); + } + + // DeleteMenu( m_macPopUpMenuId ) ; // DisposeMenu( m_macPopUpMenuHandle ) ; } bool wxChoice::Create(wxWindow *parent, wxWindowID id, @@ -221,4 +229,4 @@ wxSize wxChoice::DoGetBestSize() const } return wxSize(lbWidth, lbHeight); -} \ No newline at end of file +} diff --git a/src/mac/combobox.cpp b/src/mac/combobox.cpp index 664d142f40..feee187143 100644 --- a/src/mac/combobox.cpp +++ b/src/mac/combobox.cpp @@ -408,6 +408,10 @@ void wxComboBox::Append(const wxString& item) void wxComboBox::Delete(int n) { + if ( HasClientObjectData() ) + { + SetClientObject(n, NULL); + } m_choice->Delete( n ); }