From: Vadim Zeitlin Date: Sat, 26 Jan 2008 22:31:55 +0000 (+0000) Subject: don't append anything back in DoDeleteOneItem() if the control becomes empty (fixes... X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/ba8c878f957da36c14879b747a2d54d7fe01baa8 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 --- 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