diff --git a/sources/qetgraphicsitem/conductor.cpp b/sources/qetgraphicsitem/conductor.cpp index 4eb9009bc..a82dc5ced 100644 --- a/sources/qetgraphicsitem/conductor.cpp +++ b/sources/qetgraphicsitem/conductor.cpp @@ -1099,8 +1099,10 @@ bool Conductor::fromXml(QDomElement &dom_element) m_uuid = QUuid::createUuid(); } - setPos(dom_element.attribute("x", nullptr).toDouble(), - dom_element.attribute("y", nullptr).toDouble()); + //"nan" and "inf" parse as numbers; a non-finite position is kept at 0 + const qreal x = dom_element.attribute("x", nullptr).toDouble(); + const qreal y = dom_element.attribute("y", nullptr).toDouble(); + setPos(qIsFinite(x) ? x : 0, qIsFinite(y) ? y : 0); bool retval = pathFromXml(dom_element); @@ -1229,7 +1231,10 @@ bool Conductor::pathFromXml(const QDomElement &e) { // cette longueur doit etre un reel bool ok; qreal segment_length = current_segment.attribute("length").toDouble(&ok); - if (!ok) continue; + // toDouble() accepts "nan" and "inf". A NaN length would also pass + // the coherence check below (every comparison with NaN is false) + // and turn the whole path into NaN. + if (!ok || !qIsFinite(segment_length)) continue; if (current_segment.attribute("orientation") == "horizontal") { segments_x << segment_length; diff --git a/sources/qetgraphicsitem/conductortextitem.cpp b/sources/qetgraphicsitem/conductortextitem.cpp index 624b5ea77..a3e3127f0 100644 --- a/sources/qetgraphicsitem/conductortextitem.cpp +++ b/sources/qetgraphicsitem/conductortextitem.cpp @@ -69,13 +69,17 @@ Conductor *ConductorTextItem::parentConductor() const @param e */ void ConductorTextItem::fromXml(const QDomElement &e) { - if (e.hasAttribute("userx")) { - setPos(e.attribute("userx").toDouble(), - e.attribute("usery").toDouble()); + //A non-finite ("nan", "inf") position or rotation is ignored, + //as if the text had never been moved or rotated + const qreal x = e.attribute("userx").toDouble(); + const qreal y = e.attribute("usery").toDouble(); + if (e.hasAttribute("userx") && qIsFinite(x) && qIsFinite(y)) { + setPos(x, y); moved_by_user_ = true; } - if (e.hasAttribute("rotation")) { - setRotation(e.attribute("rotation").toDouble()); + const qreal rotation = e.attribute("rotation").toDouble(); + if (e.hasAttribute("rotation") && qIsFinite(rotation)) { + setRotation(rotation); rotate_by_user_ = true; } }