fix: resolve QPoint/QPointF type mismatch when moving vertices fixed #237#238
fix: resolve QPoint/QPointF type mismatch when moving vertices fixed #237#238feyzhen wants to merge 1 commit into
Conversation
intersection_point() returns a QPoint, which cannot be subtracted from a QPointF in shape vertices, causing a TypeError on drag. Normalize all coordinates to QPointF before arithmetic, fixing the crash when dragging vertices or moving shapes.
|
Hi @feyzhen — thanks for tracking this down and filing #237 with a clean repro. While reviewing this I found #240, which turned out to fix the same underlying issue (
#240 fixes 1 and 2 by fixing I've merged #240 (2b093a5) to close paths 1 and 2. Would you mind rebasing this PR down to just the Thanks again for catching this. |
|
Follow-up: rather than waiting on a rebase, I pulled your `bounded_move_shapes` fix out into its own PR (#241) so it could land independently of the now-redundant `bounded_move_vertex` change — merged as d91d959, with a `Co-authored-by` trailer crediting you for the fix. All three crash paths in this bug class (drawing at the edge, dragging a vertex, dragging a shape) are now fixed on `main` via #240 + #241. Closing this one out since both of its fixes are now covered — but thank you again for the original report (#237) and this fix, it saved real debugging time. |
…242) Copilot's review of #241 flagged that the left/top clamp still did int(o1.x()) before wrapping in QPointF, so sub-pixel overflows (e.g. -0.3) truncate to 0 and silently fail to correct the position. Verifying that fix surfaced a second, independent bug in the same lines: the right/bottom clamp corrects against pixmap.width()/height() instead of (width() - 1)/(height() - 1), which is the bound out_off_pixmap() actually enforces — so a shape overflowing the right or bottom edge stayed uncorrected regardless of the int() truncation. Both are pre-existing (predate #237/#238/#240/#241); this PR only touches the four lines already modified by #241. Adds a regression test covering both edges plus the original TypeError crash path.
intersection_point() returns a QPoint, which cannot be subtracted from a QPointF in shape vertices, causing a TypeError on drag. Normalize all coordinates to QPointF before arithmetic, fixing the crash when dragging vertices or moving shapes.