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:
@@ -1999,12 +1999,14 @@ int wxPGProperty::GetChoiceSelection() const
|
|||||||
|
|
||||||
void wxPGProperty::SetChoiceSelection( int newValue )
|
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
|
// Changes value of a property with choices, but only
|
||||||
// works if the value type is long or string.
|
// works if the value type is long or string.
|
||||||
wxString valueType = GetValue().GetType();
|
wxString valueType = GetValue().GetType();
|
||||||
|
|
||||||
wxCHECK_RET( m_choices.IsOk(), wxT("invalid choiceinfo") );
|
|
||||||
|
|
||||||
if ( valueType == wxPG_VARIANT_TYPE_STRING )
|
if ( valueType == wxPG_VARIANT_TYPE_STRING )
|
||||||
{
|
{
|
||||||
SetValue( m_choices.GetLabel(newValue) );
|
SetValue( m_choices.GetLabel(newValue) );
|
||||||
|
Reference in New Issue
Block a user