mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-10-10 22:24:13 +02:00
Load a picture without a usable size at size 1, not 0
DiagramImageItem::fromXml() read the size attribute with a plain toDouble(). A picture whose size was missing or not a number got size 0, so it was invisible on the folio, left out of the SVG export, and a resave wrote size="0" back, which then stayed 0 on every load. "nan" was kept and written back as such. The <transform> child, which newer files carry, already defaults its scale to 1. Read the size with an ok flag and use 1, the size a picture is added with, when it is missing, not a number, not finite, or 0. No file-format change for usable sizes. A picture that an earlier save left at size="0" shows again, at size 1, after this change. Tests: tst_imagemissingsize runs the binary's --resave and --export-svg on a fixture with six small pictures: size missing, "0", "nan", "big", "0.5" and "2". The first four fail on master (saved as 0, 0, nan, 0) and the export draws only 3 of the 6 pictures there. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Beat Hangartner <beat@hangartners.ch>
This commit is contained in:
@@ -1686,7 +1686,12 @@ bool DiagramImageItem::fromXml(const QDomElement &e)
|
||||
// pivot), the same two-tier fallback QetShapeItem's own fromXml()
|
||||
// already uses for its identical <transform> element.
|
||||
m_transform.rotation = e.attribute("rotation").toDouble();
|
||||
m_transform.scaleX = e.attribute("size").toDouble();
|
||||
//A missing, unreadable, non-finite or zero size would scale the
|
||||
//picture to nothing (and a resave wrote size="0" back): use 1,
|
||||
//the size a picture is added with, as the <transform> branch does
|
||||
bool size_ok = false;
|
||||
const qreal size = e.attribute("size").toDouble(&size_ok);
|
||||
m_transform.scaleX = (size_ok && qIsFinite(size) && size != 0) ? size : 1;
|
||||
m_transform.scaleY = m_transform.scaleX;
|
||||
m_transform.pivot = imageRect().center();
|
||||
m_pivotIsCustom = false;
|
||||
|
||||
Reference in New Issue
Block a user