Skip to content

Commit 44b4afe

Browse files
committed
fix(canvas): clear snap highlight after every paint
The NEAR_VERTEX highlight set on self.current during snap persisted on the shape state between events. Any repaint that fired without a preceding mouseMoveEvent (scroll, zoom, resize, window expose) would redraw the stale white circle at vertex 0 even though the cursor had moved far away from the snap range. Clear self.current's highlight at the end of paintEvent so transient snap state never survives across paint events. mouseMoveEvent sets it again on every move, so the live snap indicator still shows correctly. (cherry picked from commit fcb3a8e)
1 parent fb5ce6f commit 44b4afe

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

labelme/widgets/canvas.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,6 @@ def mouseMoveEvent(self, a0: QtGui.QMouseEvent) -> None:
385385
self._update_status()
386386
return
387387

388-
self.current.highlightClear()
389388
if self.outOfPixmap(pos):
390389
# Don't allow the user to draw outside the pixmap.
391390
# Project the point to the pixmap's edges.
@@ -895,6 +894,8 @@ def paintEvent(self, a0: QtGui.QPaintEvent) -> None:
895894
"ai_points_to_shape",
896895
]:
897896
p.end()
897+
if self.current is not None:
898+
self.current.highlightClear()
898899
return
899900

900901
drawing_shape: Shape = self.current.copy()
@@ -923,6 +924,8 @@ def paintEvent(self, a0: QtGui.QPaintEvent) -> None:
923924
drawing_shape.selected = self.fillDrawing()
924925
drawing_shape.paint(p)
925926
p.end()
927+
if self.current is not None:
928+
self.current.highlightClear()
926929

927930
def transformPos(self, point: QPointF) -> QPointF:
928931
"""Convert from widget-logical coordinates to painter-logical ones."""

0 commit comments

Comments
 (0)