[gtk+] GtkListBox: Fix a bug in unselection
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] GtkListBox: Fix a bug in unselection
- Date: Sat, 1 Nov 2014 02:35:48 +0000 (UTC)
commit e6e511eb460d8fcd241f202f9c3e26b0ef288927
Author: Matthias Clasen <mclasen redhat com>
Date: Fri Oct 31 22:34:09 2014 -0400
GtkListBox: Fix a bug in unselection
Ensure that gtk_list_box_get_selected_row returns NULL after
gtk_list_box_unselect_all. Add a testcase that detects this
problem.
gtk/gtklistbox.c | 2 ++
testsuite/gtk/listbox.c | 12 +++++++++---
2 files changed, 11 insertions(+), 3 deletions(-)
---
diff --git a/gtk/gtklistbox.c b/gtk/gtklistbox.c
index 5b04223..0d42117 100644
--- a/gtk/gtklistbox.c
+++ b/gtk/gtklistbox.c
@@ -1449,6 +1449,8 @@ gtk_list_box_unselect_all_internal (GtkListBox *box)
dirty |= gtk_list_box_row_set_selected (row, FALSE);
}
+ BOX_PRIV (box)->selected_row = NULL;
+
return dirty;
}
diff --git a/testsuite/gtk/listbox.c b/testsuite/gtk/listbox.c
index ce1fca8..e868f9a 100644
--- a/testsuite/gtk/listbox.c
+++ b/testsuite/gtk/listbox.c
@@ -137,11 +137,17 @@ test_selection (void)
g_assert_cmpint (count, ==, 1);
row2 = gtk_list_box_get_selected_row (list);
g_assert (row2 == row);
+ gtk_list_box_unselect_all (list);
+ row2 = gtk_list_box_get_selected_row (list);
+ g_assert (row2 == NULL);
+ gtk_list_box_select_row (list, row);
+ row2 = gtk_list_box_get_selected_row (list);
+ g_assert (row2 == row);
gtk_list_box_set_selection_mode (list, GTK_SELECTION_BROWSE);
gtk_container_remove (GTK_CONTAINER (list), GTK_WIDGET (row));
g_assert (callback_row == NULL);
- g_assert_cmpint (count, ==, 2);
+ g_assert_cmpint (count, ==, 4);
row2 = gtk_list_box_get_selected_row (list);
g_assert (row2 == NULL);
@@ -149,12 +155,12 @@ test_selection (void)
gtk_list_box_select_row (list, row);
g_assert (gtk_list_box_row_is_selected (row));
g_assert (callback_row == row);
- g_assert_cmpint (count, ==, 3);
+ g_assert_cmpint (count, ==, 5);
gtk_list_box_set_selection_mode (list, GTK_SELECTION_NONE);
g_assert (!gtk_list_box_row_is_selected (row));
g_assert (callback_row == NULL);
- g_assert_cmpint (count, ==, 4);
+ g_assert_cmpint (count, ==, 6);
row2 = gtk_list_box_get_selected_row (list);
g_assert (row2 == NULL);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]