Assert in wxGTK wxChoice::GetString() if the index is invalid
Similar to the previous commit for wxMSW. This commit is best viewed ignoring whitespace-only changes.
This commit is contained in:
parent
98aaeadf54
commit
910dfbc010
@ -278,21 +278,20 @@ wxString wxChoice::GetString(unsigned int n) const
|
||||
{
|
||||
wxCHECK_MSG( m_widget != NULL, wxEmptyString, wxT("invalid control") );
|
||||
|
||||
wxString str;
|
||||
|
||||
GtkComboBox* combobox = GTK_COMBO_BOX( m_widget );
|
||||
GtkTreeModel *model = gtk_combo_box_get_model( combobox );
|
||||
GtkTreeIter iter;
|
||||
if (gtk_tree_model_iter_nth_child (model, &iter, NULL, n))
|
||||
if (!gtk_tree_model_iter_nth_child (model, &iter, NULL, n))
|
||||
{
|
||||
wxFAIL_MSG( "invalid index" );
|
||||
return wxString();
|
||||
}
|
||||
|
||||
GValue value = G_VALUE_INIT;
|
||||
gtk_tree_model_get_value( model, &iter, m_stringCellIndex, &value );
|
||||
wxString tmp = wxGTK_CONV_BACK( g_value_get_string( &value ) );
|
||||
g_value_unset( &value );
|
||||
return tmp;
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
unsigned int wxChoice::GetCount() const
|
||||
|
Loading…
Reference in New Issue
Block a user