diff --git a/sources/qetgraphicsitem/dynamicelementtextitem.cpp b/sources/qetgraphicsitem/dynamicelementtextitem.cpp
index cb0ec0ab3..c99eb4a37 100644
--- a/sources/qetgraphicsitem/dynamicelementtextitem.cpp
+++ b/sources/qetgraphicsitem/dynamicelementtextitem.cpp
@@ -1469,7 +1469,9 @@ void DynamicElementTextItem::setPotentialConductor()
m_watched_conductor = c_list.first();
connect(m_watched_conductor.data(), &Conductor::propertiesChange, this, &DynamicElementTextItem::conductorPropertiesChanged);
}
- else if(m_watched_conductor.isNull() && m_other_report)
+ else if(m_watched_conductor.isNull() && m_other_report
+ //A report symbol can have no terminal (some older collections')
+ && !m_other_report.data()->terminals().isEmpty())
{
if (!m_other_report.data()->terminals().first()->conductors().isEmpty())
{
diff --git a/tests/qttest/tst_resaveunchanged.cpp b/tests/qttest/tst_resaveunchanged.cpp
index 9daf85886..f372f99d7 100644
--- a/tests/qttest/tst_resaveunchanged.cpp
+++ b/tests/qttest/tst_resaveunchanged.cpp
@@ -227,6 +227,61 @@ private slots:
QVERIFY(references > 0);
}
+ // A folio report arrow linked to one that has no terminal -- such as
+ // ref_voyant_2_h.elmt from the collection -- crashed QElectroTech on
+ // opening: the arrow's text looked for a wire on the other arrow's
+ // first terminal. Projet_vierge.qet with a previous-folio arrow (one
+ // terminal, a label text) on folio 1 linked to a ref_voyant_2_h on
+ // folio 2.
+ void reportArrowWithoutTerminalOpens()
+ {
+ QByteArray xml = read(QStringLiteral(QET_EXAMPLES_DIR "/Projet_vierge.qet"));
+ const QByteArray a = "{0a000000-0000-4000-8000-00000000000a}",
+ b = "{0b000000-0000-4000-8000-00000000000b}";
+ const QByteArray arrow =
+ ""
+ ""
+ ""
+ "xlabel"
+ "";
+ const QByteArray no_terminal =
+ ""
+ ""
+ "";
+ QVERIFY(xml.contains("ref_voyant_2_h.elmt") && xml.contains("01previous_folio.elmt"));
+ // put @p element first in the elements of folio @p n
+ auto put = [&xml](int n, const QByteArray &element) {
+ int at = -1;
+ for (int i = 0 ; i <= n ; ++i) {
+ at = xml.indexOf("", at), open = xml.indexOf("", at),
+ end = xml.indexOf("", at);
+ if (empty >= 0 && empty < end && (open < 0 || empty < open))
+ xml.replace(empty, int(qstrlen("")), "" + element + "");
+ else if (open >= 0 && open < end)
+ xml.insert(open + int(qstrlen("")), element);
+ else
+ return false;
+ return true;
+ };
+ QVERIFY(put(0, arrow));
+ QVERIFY(put(1, no_terminal));
+ const QString in = m_dir.filePath(QStringLiteral("report_without_terminal.qet"));
+ QFile f(in);
+ QVERIFY(f.open(QIODevice::WriteOnly));
+ f.write(xml);
+ f.close();
+ const QString saved = resave(in);
+ QVERIFY2(!saved.isEmpty(), "--resave failed: QElectroTech crashed opening the project");
+ QVERIFY2(read(saved).contains(b), "the arrow without a terminal was not kept");
+ }
+
// A title-block value that is a single space is kept through two saves
// (#973), and a value with accents comes back as it went in.
void singleSpaceValueKept()