X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/372c2812d998fb9fb34ba1a8cf148768450a1bbf..e97251c58ea8b3676ec05ecccdcae77c61e97a10:/src/univ/listbox.cpp diff --git a/src/univ/listbox.cpp b/src/univ/listbox.cpp index 725eafa5ec..7ae71b51fe 100644 --- a/src/univ/listbox.cpp +++ b/src/univ/listbox.cpp @@ -127,6 +127,8 @@ bool wxListBox::Create(wxWindow *parent, wxListBox::~wxListBox() { + // call this just to free the client data -- and avoid leaking memory + DoClear(); } // ---------------------------------------------------------------------------- @@ -272,7 +274,8 @@ void wxListBox::Clear() void wxListBox::Delete(int n) { - wxCHECK_RET( n < GetCount(), _T("invalid index in wxListBox::Delete") ); + wxCHECK_RET( n >= 0 && n < GetCount(), + _T("invalid index in wxListBox::Delete") ); // do it before removing the index as otherwise the last item will not be // refreshed (as GetCount() will be decremented) @@ -1007,7 +1010,7 @@ void wxListBox::ExtendSelection(int itemTo) } } -void wxListBox::Select(bool sel, int item) +void wxListBox::DoSelect(int item, bool sel) { if ( item != -1 ) { @@ -1027,7 +1030,7 @@ void wxListBox::Select(bool sel, int item) void wxListBox::SelectAndNotify(int item) { - Select(TRUE, item); + DoSelect(item); SendEvent(wxEVT_COMMAND_LISTBOX_SELECTED); } @@ -1046,7 +1049,7 @@ void wxListBox::Activate(int item) if ( item != -1 ) { - Select(TRUE, item); + DoSelect(item); SendEvent(wxEVT_COMMAND_LISTBOX_DOUBLECLICKED); } @@ -1089,7 +1092,7 @@ bool wxListBox::PerformAction(const wxControlAction& action, item = m_current; if ( IsSelected(item) ) - Unselect(item); + DoUnselect(item); else SelectAndNotify(item); } @@ -1100,12 +1103,12 @@ bool wxListBox::PerformAction(const wxControlAction& action, if ( strArg.empty() ) SelectAndNotify(item); else - Select(TRUE, item); + DoSelect(item); } else if ( action == wxACTION_LISTBOX_SELECTADD ) - Select(TRUE, item); + DoSelect(item); else if ( action == wxACTION_LISTBOX_UNSELECT ) - Select(FALSE, item); + DoUnselect(item); else if ( action == wxACTION_LISTBOX_MOVEDOWN ) ChangeCurrent(1); else if ( action == wxACTION_LISTBOX_MOVEUP )