Check if new index is in range before selecting new value in wxPGProperty::SetChoiceSelection.

Closes #16697

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@78210 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Artur Wieczorek 2014-11-29 16:45:21 +00:00
parent f34f9d6708
commit 29bf859fae

View File

@ -1999,12 +1999,14 @@ int wxPGProperty::GetChoiceSelection() const
void wxPGProperty::SetChoiceSelection( int newValue )
{
wxCHECK_RET( m_choices.IsOk(), wxT("invalid choiceinfo") );
wxCHECK_RET( newValue >= 0 && newValue < (int)m_choices.GetCount(),
wxT("New index is out of range") );
// Changes value of a property with choices, but only
// works if the value type is long or string.
wxString valueType = GetValue().GetType();
wxCHECK_RET( m_choices.IsOk(), wxT("invalid choiceinfo") );
if ( valueType == wxPG_VARIANT_TYPE_STRING )
{
SetValue( m_choices.GetLabel(newValue) );