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 <noreply@anthropic.com>
Signed-off-by: Beat Hangartner <beat@hangartners.ch>
This commit is contained in:
Beat Hangartner
2026-10-07 21:10:38 +02:00
parent ef795a21e5
commit 0795281d79
2 changed files with 2 additions and 2 deletions
+1 -1
View File
@@ -127,6 +127,6 @@ class PartLine : public CustomElementGraphicPart
int m_vector_index = -1;
QPropertyUndoCommand *m_undo_command;
QVector<QetGraphicsHandlerItem *> m_handler_vector;
qreal m_rot;
qreal m_rot = 0;
};
#endif
+1 -1
View File
@@ -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