From ba8c878f957da36c14879b747a2d54d7fe01baa8 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 26 Jan 2008 22:31:55 +0000 Subject: [PATCH] don't append anything back in DoDeleteOneItem() if the control becomes empty (fixes bug 1880411) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@51389 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/gtk/choice.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/gtk/choice.cpp b/src/gtk/choice.cpp index 294d977377..af2b1092fd 100644 --- a/src/gtk/choice.cpp +++ b/src/gtk/choice.cpp @@ -222,8 +222,8 @@ void wxChoice::DoDeleteOneItem(unsigned int n) wxArrayString items; wxArrayPtrVoid itemsData; - items.Alloc(count); - itemsData.Alloc(count); + items.Alloc(count - 1); + itemsData.Alloc(count - 1); for ( unsigned i = 0; i < count; i++ ) { if ( i != n ) @@ -235,11 +235,15 @@ void wxChoice::DoDeleteOneItem(unsigned int n) wxChoice::DoClear(); - void ** const data = &itemsData[0]; - if ( HasClientObjectData() ) - Append(items, wx_reinterpret_cast(wxClientData **, data)); - else - Append(items, data); + if ( count > 1 ) + { + void ** const data = &itemsData[0]; + if ( HasClientObjectData() ) + Append(items, wx_reinterpret_cast(wxClientData **, data)); + else + Append(items, data); + } + //else: the control is now empty, nothing to append } int wxChoice::FindString( const wxString &string, bool bCase ) const -- 2.50.0