mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-10-04 09:54:13 +02:00
Fix bugtracker #266: skip shapes with a nan coordinate in the element editor
A symbol with a "nan" or "inf" coordinate (bugtracker #266 had a line with x1="nan" x2="nan") opened with that shape invisible and the view off-centre. Moving the selection then snapped NaN through qRound() to INT_MIN, and saving wrote width="-2147483630", breaking the symbol. The folio already leaves such a shape out (ElementPictureFactory reads it with QET::attributeIsAReal()). Do the same in the element editor, and have --check-elements warn about it. Only geometry attributes are read, so a text whose content is "inf" is not affected. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1272,6 +1272,14 @@ ElementContent ElementScene::loadContent(const QDomDocument &xml_document)
|
||||
CustomElementPart *cep = nullptr;
|
||||
PartDynamicTextField *pdtf = nullptr;
|
||||
|
||||
//A shape with a "nan" or "inf" coordinate is not drawn
|
||||
//on the folio either; loading it would only break the view
|
||||
if (QET::hasNonFiniteGeometry(qde)) {
|
||||
qWarning() << "Element editor: skipped a" << qde.tagName()
|
||||
<< "with a non-finite coordinate";
|
||||
continue;
|
||||
}
|
||||
|
||||
if (qde.tagName() == "line") cep = new PartLine (m_element_editor);
|
||||
else if (qde.tagName() == "rect") cep = new PartRectangle (m_element_editor);
|
||||
else if (qde.tagName() == "ellipse") cep = new PartEllipse (m_element_editor);
|
||||
|
||||
Reference in New Issue
Block a user