Fix selection corner cases in wxOSX wxComboBox.

Don't crash in wxComboBox::GetString() if it's passed an invalid index.

Don't call GetString() with invalid index from GetStringSelection() if there
is no selection.

Do accept wxNOT_FOUND in SetSelectedItem() as it means, according to the docs,
that the existing selection should be reset.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@65384 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2010-08-22 22:15:32 +00:00
parent 5623dce7cd
commit 6f07c007a5
2 changed files with 18 additions and 3 deletions

View File

@@ -186,12 +186,15 @@ int wxComboBox::FindString(const wxString& s, bool bCase) const
wxString wxComboBox::GetString(unsigned int n) const
{
wxCHECK_MSG( n < GetCount(), wxString(), "Invalid combobox index" );
return GetComboPeer()->GetStringAtIndex(n);
}
wxString wxComboBox::GetStringSelection() const
{
return GetString(GetSelection());
const int sel = GetSelection();
return sel == wxNOT_FOUND ? wxString() : GetString(sel);
}
void wxComboBox::SetString(unsigned int n, const wxString& s)