From 0795281d79948953260d84393f65a6c0243c4882 Mon Sep 17 00:00:00 2001 From: Beat Hangartner Date: Wed, 7 Oct 2026 21:10:38 +0200 Subject: [PATCH] Initialise the rotation of a new line and polygon in the element editor PartLine and PartPolygon keep their rotation in m_rot, which nothing sets until setRotation() is called. rotation() reads it, and setRotation() computes the difference from it, so the first rotate of a freshly drawn line or polygon in the element editor starts from garbage: qRound(m_rot * 100.0) on an arbitrary value is undefined behaviour, and the angle stored afterwards is arbitrary too. PartRectangle and PartEllipse already start at 0. Give m_rot a default value of 0 in both headers, as PartEllipse has. Only the two headers change. No file-format change, and no change for a part loaded from a file or rotated once, since both set m_rot before reading it. Tests: none of their own; an uninitialised read is what a sanitizer finds, and this one is the same kind as the BorderTitleBlock and ConductorProfile fixes (#1358, #1359). ctest on macOS, and all example projects through --resave and --export-svg, unchanged. Co-Authored-By: Claude Fable 5.1 Signed-off-by: Beat Hangartner --- sources/editor/graphicspart/partline.h | 2 +- sources/editor/graphicspart/partpolygon.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sources/editor/graphicspart/partline.h b/sources/editor/graphicspart/partline.h index 1e3082a53..7d09b7d60 100644 --- a/sources/editor/graphicspart/partline.h +++ b/sources/editor/graphicspart/partline.h @@ -127,6 +127,6 @@ class PartLine : public CustomElementGraphicPart int m_vector_index = -1; QPropertyUndoCommand *m_undo_command; QVector m_handler_vector; - qreal m_rot; + qreal m_rot = 0; }; #endif diff --git a/sources/editor/graphicspart/partpolygon.h b/sources/editor/graphicspart/partpolygon.h index bee786be4..f2d959460 100644 --- a/sources/editor/graphicspart/partpolygon.h +++ b/sources/editor/graphicspart/partpolygon.h @@ -119,6 +119,6 @@ class PartPolygon : public CustomElementGraphicPart QAction *m_insert_point, *m_remove_point; QPointF m_context_menu_pos; - qreal m_rot; + qreal m_rot = 0; }; #endif