summaryrefslogtreecommitdiff
path: root/gtk/gtkselectionmodel.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2019-02-13 08:38:30 -0500
committerMatthias Clasen <mclasen@redhat.com>2019-02-13 08:38:30 -0500
commitf4b26af2554aa546740409ef2da91a62397cd159 (patch)
treed79c8f5e9f9b8bda017fc900c5084baaa757e26c /gtk/gtkselectionmodel.c
parent2bd93303c4fde5e3b2c7490f7cdb55b5c9d47d6a (diff)
downloadgtk+-f4b26af2554aa546740409ef2da91a62397cd159.tar.gz
selection model: Add sanity checks
It is easy to emit wrong ::selection-changed signals, and then bad things will usually happen later. Add some sanity checks to gtk_selection_model_selection_changed to make this easier to track down.
Diffstat (limited to 'gtk/gtkselectionmodel.c')
-rw-r--r--gtk/gtkselectionmodel.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/gtk/gtkselectionmodel.c b/gtk/gtkselectionmodel.c
index 0be3961bc2..137928c687 100644
--- a/gtk/gtkselectionmodel.c
+++ b/gtk/gtkselectionmodel.c
@@ -295,6 +295,8 @@ gtk_selection_model_selection_changed (GtkSelectionModel *model,
guint n_items)
{
g_return_if_fail (GTK_IS_SELECTION_MODEL (model));
+ g_return_if_fail (n_items > 0);
+ g_return_if_fail (position + n_items <= g_list_model_get_n_items (G_LIST_MODEL (model)));
g_signal_emit (model, signals[SELECTION_CHANGED], 0, position, n_items);
}