diff --git a/lib/mu-container.c b/lib/mu-container.c index 73587c92..c2a676a3 100644 --- a/lib/mu-container.c +++ b/lib/mu-container.c @@ -200,8 +200,8 @@ mu_container_remove_child (MuContainer *c, MuContainer *child) g_return_val_if_fail (c, NULL); g_return_val_if_fail (child, NULL); - g_assert (!child->child); - g_return_val_if_fail (!child->child, NULL); + /* g_assert (!child->child); */ + /* g_return_val_if_fail (!child->child, NULL); */ g_return_val_if_fail (c != child, NULL); c->child = mu_container_remove_sibling (c->child, child); diff --git a/lib/mu-threader.c b/lib/mu-threader.c index 5efc962f..46660831 100644 --- a/lib/mu-threader.c +++ b/lib/mu-threader.c @@ -285,8 +285,18 @@ handle_references (GHashTable *id_table, MuContainer *c) /* optimization: if the the message was newly added, it's by * definition not reachable yet */ - if (child_elligible (parent, c, created)) + + if (parent && c && !(c->child && mu_container_reachable (c->child, parent))) { + + /* if c already has a parent, remove c from its parent children + and reparent it, as now we know who is c's parent reliably */ + if (c->parent) { + mu_container_remove_child(c->parent, c); + c->next = c->last = c->parent = NULL; + } + parent = mu_container_append_children (parent, c); + } }