Commit 02908345 authored by Milan Bouchet-Valat's avatar Milan Bouchet-Valat

[GtkComboBoxText] Add checks for id-column/entry-text-column >= 0

If the GtkComboBoxText doesn't have id-column or entry-text-column
set for some reason (value -1), better warn and return. Else, unrelated
assertions fail, and warnings from gtk_tree_model_get_column_type()
are printed, which are not really obvious.
parent 3b90d877
......@@ -265,6 +265,7 @@ gtk_combo_box_text_insert (GtkComboBoxText *combo_box,
store = GTK_LIST_STORE (gtk_combo_box_get_model (GTK_COMBO_BOX (combo_box)));
g_return_if_fail (GTK_IS_LIST_STORE (store));
text_column = gtk_combo_box_get_entry_text_column (GTK_COMBO_BOX (combo_box));
g_return_if_fail (text_column >= 0);
column_type = gtk_tree_model_get_column_type (GTK_TREE_MODEL (store), text_column);
g_return_if_fail (column_type == G_TYPE_STRING);
......@@ -276,6 +277,7 @@ gtk_combo_box_text_insert (GtkComboBoxText *combo_box,
gint id_column;
id_column = gtk_combo_box_get_id_column (GTK_COMBO_BOX (combo_box));
g_return_if_fail (id_column >= 0);
column_type = gtk_tree_model_get_column_type (GTK_TREE_MODEL (store), id_column);
g_return_if_fail (column_type == G_TYPE_STRING);
......@@ -359,6 +361,7 @@ gtk_combo_box_text_get_active_text (GtkComboBoxText *combo_box)
model = gtk_combo_box_get_model (GTK_COMBO_BOX (combo_box));
g_return_val_if_fail (GTK_IS_LIST_STORE (model), NULL);
text_column = gtk_combo_box_get_entry_text_column (GTK_COMBO_BOX (combo_box));
g_return_val_if_fail (text_column >= 0, NULL);
column_type = gtk_tree_model_get_column_type (model, text_column);
g_return_val_if_fail (column_type == G_TYPE_STRING, NULL);
gtk_tree_model_get (model, &iter, text_column, &text, -1);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment