Skip to content

Commit

Permalink
Handle empty dotcode nodes. (#290)
Browse files Browse the repository at this point in the history
Modern versions of pydot can end up returning nodes
corresponding to the empty string, i.e. "\n".  Make sure
to ignore nodes of this kind, as that is a new behavior.

Signed-off-by: Chris Lalancette <clalancette@gmail.com>
  • Loading branch information
clalancette authored Apr 1, 2024
1 parent b7a51f0 commit 21adf04
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions qt_dotgraph/src/qt_dotgraph/dot_to_qt.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,6 @@ def dotcode_to_qt_items(self, dotcode, highlight_level, same_label_siblings=Fals
if isinstance(graph, list):
graph = graph[0]

# graph = pygraphviz.AGraph(string=self._current_dotcode, strict=False, directed=True)
# graph.layout(prog='dot')

nodes = self.parse_nodes(graph, highlight_level, scene=scene)
edges = self.parse_edges(graph, nodes, highlight_level, same_label_siblings, scene=scene)
return nodes, edges
Expand All @@ -281,13 +278,17 @@ def parse_nodes(self, graph, highlight_level, scene=None):
subgraph.nodes_iter = subgraph.get_node_list
nodes[subgraph.get_name()] = subgraph_nodeitem
for node in subgraph.nodes_iter():
if node.get_name() == r'"\n"':
continue
# hack required by pydot
if node.get_name() in ('graph', 'node', 'empty'):
continue
nodes[node.get_name()] = \
self.getNodeItemForNode(node, highlight_level, scene=scene)
for node in graph.nodes_iter():
# hack required by pydot
if node.get_name() == r'"\n"':
continue
if node.get_name() in ('graph', 'node', 'empty'):
continue
nodes[node.get_name()] = self.getNodeItemForNode(node, highlight_level, scene=scene)
Expand Down

0 comments on commit 21adf04

Please sign in to comment.