[gtk+] gtktreemodelfilter: fix corner case in rows-reordered handling
- From: Kristian Rietveld <kristian src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] gtktreemodelfilter: fix corner case in rows-reordered handling
- Date: Sun, 11 Sep 2011 10:17:08 +0000 (UTC)
commit 9ed76387fa2d91d7ac063ff1ce6d2cace84d7688
Author: Kristian Rietveld <kris gtk org>
Date: Sun Sep 11 12:00:00 2011 +0200
gtktreemodelfilter: fix corner case in rows-reordered handling
If the level to be reordered did not contain an elt with offset == 0
(for example if that node was hidden), the first reference was not
correctly transferred.
A unit test for this has been added in a previous commit.
gtk/gtktreemodelfilter.c | 16 +++++++---------
1 files changed, 7 insertions(+), 9 deletions(-)
---
diff --git a/gtk/gtktreemodelfilter.c b/gtk/gtktreemodelfilter.c
index bf954e1..a8795fb 100644
--- a/gtk/gtktreemodelfilter.c
+++ b/gtk/gtktreemodelfilter.c
@@ -2698,7 +2698,7 @@ gtk_tree_model_filter_rows_reordered (GtkTreeModel *c_model,
GSequence *tmp_seq;
GSequenceIter *tmp_end_iter;
- GSequenceIter *old_first_elt = NULL;
+ GSequenceIter *old_first_siter = NULL;
gint *tmp_array;
gint i, elt_count;
gint length;
@@ -2818,6 +2818,8 @@ gtk_tree_model_filter_rows_reordered (GtkTreeModel *c_model,
tmp_array = g_new (gint, g_sequence_get_length (level->visible_seq));
elt_count = 0;
+ old_first_siter = g_sequence_get_iter_at_pos (level->seq, 0);
+
for (i = 0; i < length; i++)
{
FilterElt *elt;
@@ -2827,10 +2829,6 @@ gtk_tree_model_filter_rows_reordered (GtkTreeModel *c_model,
if (elt == NULL)
continue;
- /* Keep a reference if this elt has old_pos == 0 */
- if (new_order[i] == 0)
- old_first_elt = siter;
-
/* Only for visible items an entry should be present in the order array
* to be emitted.
*/
@@ -2848,15 +2846,15 @@ gtk_tree_model_filter_rows_reordered (GtkTreeModel *c_model,
g_sequence_sort (level->visible_seq, filter_elt_cmp, NULL);
/* Transfer the reference from the old item at position 0 to the
- * new item at position 0.
+ * new item at position 0, unless the old item at position 0 is also
+ * at position 0 in the new sequence.
*/
- if (old_first_elt && g_sequence_iter_get_position (old_first_elt))
+ if (g_sequence_iter_get_position (old_first_siter) != 0)
gtk_tree_model_filter_level_transfer_first_ref (filter,
level,
- old_first_elt,
+ old_first_siter,
g_sequence_get_iter_at_pos (level->seq, 0));
-
/* emit rows_reordered */
if (g_sequence_get_length (level->visible_seq) > 0)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]