From cddccd22989e4fb859795579435b28257d13b2bc Mon Sep 17 00:00:00 2001 From: Viet-Anh Nguyen Date: Sat, 11 Jul 2026 11:45:38 +0700 Subject: [PATCH] fix: resolve QPoint/QPointF mismatch in bounded_move_shapes bounded_move_shapes() mixed QPointF (pos, from mouse events) with QPoint literals when clamping a dragged shape to the pixmap border, raising a TypeError when a selected shape is dragged near the image edge. This is the same class of bug as #237/#240 (intersection_point returning QPoint) but an independent instance, since this path never calls intersection_point(). Co-authored-by: chaosbee --- anylabeling/views/labeling/widgets/canvas.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/anylabeling/views/labeling/widgets/canvas.py b/anylabeling/views/labeling/widgets/canvas.py index 2744a4a..471c360 100644 --- a/anylabeling/views/labeling/widgets/canvas.py +++ b/anylabeling/views/labeling/widgets/canvas.py @@ -632,12 +632,14 @@ def bounded_move_shapes(self, shapes, pos): return False # No need to move o1 = pos + self.offsets[0] if self.out_off_pixmap(o1): - pos -= QtCore.QPoint(min(0, int(o1.x())), min(0, int(o1.y()))) + pos -= QtCore.QPointF( + float(min(0, int(o1.x()))), float(min(0, int(o1.y()))) + ) o2 = pos + self.offsets[1] if self.out_off_pixmap(o2): - pos += QtCore.QPoint( - min(0, int(self.pixmap.width() - o2.x())), - min(0, int(self.pixmap.height() - o2.y())), + pos += QtCore.QPointF( + float(min(0, int(self.pixmap.width() - o2.x()))), + float(min(0, int(self.pixmap.height() - o2.y()))), ) # XXX: The next line tracks the new position of the cursor # relative to the shape, but also results in making it