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:
@@ -278,21 +278,20 @@ wxString wxChoice::GetString(unsigned int n) const
|
|||||||
{
|
{
|
||||||
wxCHECK_MSG( m_widget != NULL, wxEmptyString, wxT("invalid control") );
|
wxCHECK_MSG( m_widget != NULL, wxEmptyString, wxT("invalid control") );
|
||||||
|
|
||||||
wxString str;
|
|
||||||
|
|
||||||
GtkComboBox* combobox = GTK_COMBO_BOX( m_widget );
|
GtkComboBox* combobox = GTK_COMBO_BOX( m_widget );
|
||||||
GtkTreeModel *model = gtk_combo_box_get_model( combobox );
|
GtkTreeModel *model = gtk_combo_box_get_model( combobox );
|
||||||
GtkTreeIter iter;
|
GtkTreeIter iter;
|
||||||
if (gtk_tree_model_iter_nth_child (model, &iter, NULL, n))
|
if (!gtk_tree_model_iter_nth_child (model, &iter, NULL, n))
|
||||||
{
|
{
|
||||||
GValue value = G_VALUE_INIT;
|
wxFAIL_MSG( "invalid index" );
|
||||||
gtk_tree_model_get_value( model, &iter, m_stringCellIndex, &value );
|
return wxString();
|
||||||
wxString tmp = wxGTK_CONV_BACK( g_value_get_string( &value ) );
|
|
||||||
g_value_unset( &value );
|
|
||||||
return tmp;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return str;
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int wxChoice::GetCount() const
|
unsigned int wxChoice::GetCount() const
|
||||||
|
Reference in New Issue
Block a user