diff --git a/zxlive/graphscene.py b/zxlive/graphscene.py index 3b5ebf9..ff54c02 100644 --- a/zxlive/graphscene.py +++ b/zxlive/graphscene.py @@ -117,6 +117,7 @@ def update_graph(self, new: GraphT, select_new: bool = False) -> None: anim_v.stop() selected_vertices.discard(v) self.removeItem(v_item) + del self.vertex_map[v] for e in diff.removed_edges: edge_idx = len(self.edge_map[e]) - 1 @@ -129,6 +130,8 @@ def update_graph(self, new: GraphT, select_new: bool = False) -> None: self.edge_map[e].pop(edge_idx) s, t = self.g.edge_st(e) self.update_edge_curves(s, t) + if len(self.edge_map[e]) == 0: + del self.edge_map[e] new_g = diff.apply_diff(self.g) # Mypy issue: https://github.com/python/mypy/issues/11673 diff --git a/zxlive/vitem.py b/zxlive/vitem.py index c9bfa07..e9c8528 100644 --- a/zxlive/vitem.py +++ b/zxlive/vitem.py @@ -110,6 +110,7 @@ def ty(self) -> VertexType: _ty: VertexType = self.g.type(self.v) return _ty + @property def is_dragging(self) -> bool: return self._old_pos is not None @@ -424,7 +425,7 @@ def __init__(self, v_item: VItem) -> None: def refresh(self) -> None: """Call this when a vertex moves or its phase changes""" - vertex_type = self.v_item.g.type(self.v_item.v) + vertex_type = self.v_item.ty if vertex_type == VertexType.Z_BOX: self.setPlainText(str(get_z_box_label(self.v_item.g, self.v_item.v))) elif vertex_type != VertexType.BOUNDARY: