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:
ispyisail
2026-10-01 15:21:51 +13:00
parent 7f799bb425
commit 75a7e642e0
4 changed files with 50 additions and 0 deletions
+13
View File
@@ -529,6 +529,19 @@ int checkOneElement(const QString &path)
return 2;
}
// QET loads the element but leaves out a shape with a "nan" or "inf"
// coordinate, on the folio and in the element editor.
const QDomNodeList description = root.elementsByTagName("description");
for (QDomNode n = description.isEmpty() ? QDomNode()
: description.at(0).firstChild() ;
!n.isNull() ; n = n.nextSibling()) {
const QDomElement shape = n.toElement();
if (!shape.isNull() && QET::hasNonFiniteGeometry(shape)) {
out << "WARN " << path << " (<" << shape.tagName()
<< "> with a non-finite coordinate is not drawn)\n";
return 1;
}
}
// Negative dimensions are malformed but QET still loads them; surface as a
// warning rather than a failure so this agrees with QET's own loader.
if (w < 0 || h < 0) {