# HG changeset patch # User Edouard Tisserant # Date 1587715333 -7200 # Node ID 69f395c01c09b34d7211f87858f50825db3d13d2 # Parent b07ad97e6019ee6d241754b0a0f43b72ff03a210 SVGHMI: Fix flawed logic to place nodes in the HMI tree, leading to wrecked tree in some cases. diff -r b07ad97e6019 -r 69f395c01c09 svghmi/svghmi.py --- a/svghmi/svghmi.py Sun Apr 19 22:44:41 2020 +0200 +++ b/svghmi/svghmi.py Fri Apr 24 10:02:13 2020 +0200 @@ -78,10 +78,15 @@ in_common +=1 else: break - if in_common > known_best_match: + # Match can only be HMI_NODE, and the whole path of node + # must match candidate node (except for name part) + # since candidate would become child of that node + if in_common > known_best_match and \ + child.nodetype == "HMI_NODE" and \ + in_common == len(child.path) - 1: known_best_match = in_common best_child = child - if best_child is not None and best_child.nodetype == "HMI_NODE": + if best_child is not None: best_child.place_node(node) else: self.children.append(node)