From 64aee7b4301e720a7420ab8942ef88f72d7a2c99 Mon Sep 17 00:00:00 2001
From: Cyrille Bagard <nocbos@gmail.com>
Date: Fri, 15 May 2015 20:30:43 +0000
Subject: Avoided crashes in graph views by filtering middle pending positions.

git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@537 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
---
 ChangeLog                     |  5 +++++
 src/gtkext/graph/nodes/flow.c | 12 +++++++++++-
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index 046a4f2..c269fa0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+15-05-15  Cyrille Bagard <nocbos@gmail.com>
+
+	* src/gtkext/graph/nodes/flow.c:
+	Avoid crashes in graph views by filtering middle pending positions.
+
 15-05-14  Cyrille Bagard <nocbos@gmail.com>
 
 	* src/glibext/gcodebuffer.c:
diff --git a/src/gtkext/graph/nodes/flow.c b/src/gtkext/graph/nodes/flow.c
index 2f822bd..343f916 100644
--- a/src/gtkext/graph/nodes/flow.c
+++ b/src/gtkext/graph/nodes/flow.c
@@ -385,7 +385,17 @@ static void g_flow_node_prepare_x_line(GFlowNode *node, GGraphNode *nodes)
                 pos.left_node = G_GRAPH_NODE(target_a);
                 pos.right_node = G_GRAPH_NODE(target_b);
 
-                g_graph_node_set_pending_position(base, PPF_MIDDLE_OF, pos);
+                /**
+                 * Un pré-condition pour pouvoir s'aligner est que les noeuds
+                 * de références soient traités au préalables pour les positions.
+                 * Sinon les assert() coincent dans g_virtual_node_apply_x_line().
+                 */
+
+                if (g_graph_node_find_container_at_same_level(nodes, base, pos.left_node) != NULL
+                    && g_graph_node_find_container_at_same_level(nodes, base, pos.right_node) != NULL)
+                {
+                    g_graph_node_set_pending_position(base, PPF_MIDDLE_OF, pos);
+                }
 
                 break;
 
-- 
cgit v0.11.2-87-g4458