Skip to content

Commit

Permalink
Merge pull request #358 from zxcalc/bug-fix-deleted-vertex
Browse files Browse the repository at this point in the history
Fix bug which generates same type of error also mentioned in #310.
  • Loading branch information
jvdwetering authored Oct 22, 2024
2 parents 1635e9f + ea25cba commit 8d6fceb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 3 additions & 0 deletions zxlive/graphscene.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion zxlive/vitem.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 8d6fceb

Please sign in to comment.