mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-10-08 13:04:13 +02:00
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:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user