summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPatrick McDermott <pj@pehjota.net>2017-10-24 20:19:02 (EDT)
committer Patrick McDermott <pj@pehjota.net>2017-10-24 20:19:02 (EDT)
commit5f76a52e558a8069fe39ed668e96e9e14165dad3 (patch)
tree9ff54b5f1a6c49847ead839c2bc4328903d28a65 /src
parent1f8fc99cabe1acd886342e7c61e5e492fea125d1 (diff)
downloadmarquee-5f76a52e558a8069fe39ed668e96e9e14165dad3.zip
marquee-5f76a52e558a8069fe39ed668e96e9e14165dad3.tar.gz
marquee-5f76a52e558a8069fe39ed668e96e9e14165dad3.tar.bz2
mq_tree_foreach_from(): Fix upward traversal
Steps to reproduce bug: 1. From tab 1, append a new child 2. From tab 1, insert a new sibling 3. From tab 1, insert a new sibling The position of the last tab (the next sibling of the new tab inserted in step 3) gets updated twice. Tree debugging output: Traversing tree from position, starting at 0x12bf620 0x12bf620 0x1272f80 0x1272f80 Inserted sibling 0x12bf620, new tree (size 5): 0xe7f7f0 (size 5, position 0) 0xed3e10 (size 2, position 1) 0x114ef40 (size 1, position 2) 0x12bf620 (size 1, position 3) 0x1272f80 (size 1, position 5)
Diffstat (limited to 'src')
-rw-r--r--src/tree.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/tree.c b/src/tree.c
index ece8594..c3e2323 100644
--- a/src/tree.c
+++ b/src/tree.c
@@ -254,16 +254,17 @@ static gboolean
foreach_up(MqTree *node, gboolean (*cb)(MqTree *node, gpointer user_data),
gpointer user_data)
{
- if (node->next) {
- if (foreach_down(node->next, cb, user_data) == MQ_TREE_STOP) {
- return MQ_TREE_STOP;
- }
+ node = node->parent;
+ if (!node) {
+ return MQ_TREE_CONTINUE;
}
- if (node->parent) {
- if (foreach_up(node->parent, cb, user_data) == MQ_TREE_STOP) {
- return MQ_TREE_STOP;
- }
+ if (foreach_down(node->next, cb, user_data) == MQ_TREE_STOP) {
+ return MQ_TREE_STOP;
+ }
+
+ if (foreach_up(node, cb, user_data) == MQ_TREE_STOP) {
+ return MQ_TREE_STOP;
}
return MQ_TREE_CONTINUE;