From fe8498a26c5169864e11d96947cf339685b5b75a Mon Sep 17 00:00:00 2001 From: ispyisail Date: Fri, 2 Oct 2026 19:40:31 +1300 Subject: [PATCH] Fix %{machine_manufacturer_reference_auxiliary1..4} never resolving AssignVariables::replaceVariable() is a fixed list of replacements. Every auxiliary family is listed for blocks 1 to 4 except the machine manufacturer reference, which stopped at the plain %{machine_manufacturer_reference}. A text using one of the four auxiliary forms printed the variable itself on the folio and in exports. Add the four, next to their manufacturer-reference neighbours. Test: tst_resaveunchanged resaves a project with one terminal whose texts combine each machine reference variable with its neighbour, and checks the saved texts carry the values. It fails without the fix (the variable is saved as typed) and passes with it. Co-Authored-By: Claude Opus 5.5 (1M context) --- sources/autoNum/assignvariables.cpp | 4 + .../qttest/fixtures/aux_machine_reference.qet | 270 ++++++++++++++++++ tests/qttest/tst_resaveunchanged.cpp | 20 ++ 3 files changed, 294 insertions(+) create mode 100644 tests/qttest/fixtures/aux_machine_reference.qet diff --git a/sources/autoNum/assignvariables.cpp b/sources/autoNum/assignvariables.cpp index 3aa46b54c..ac92a4e9f 100644 --- a/sources/autoNum/assignvariables.cpp +++ b/sources/autoNum/assignvariables.cpp @@ -304,6 +304,7 @@ namespace autonum str.replace("%{designation_auxiliary1}", dc.value("designation_auxiliary1").toString()); str.replace("%{manufacturer_auxiliary1}", dc.value("manufacturer_auxiliary1").toString()); str.replace("%{manufacturer_reference_auxiliary1}", dc.value("manufacturer_reference_auxiliary1").toString()); + str.replace("%{machine_manufacturer_reference_auxiliary1}", dc.value("machine_manufacturer_reference_auxiliary1").toString()); str.replace("%{supplier_auxiliary1}", dc.value("supplier_auxiliary1").toString()); str.replace("%{quantity_auxiliary1}", dc.value("quantity_auxiliary1").toString()); str.replace("%{unity_auxiliary1}", dc.value("unity_auxiliary1").toString()); @@ -313,6 +314,7 @@ namespace autonum str.replace("%{designation_auxiliary2}", dc.value("designation_auxiliary2").toString()); str.replace("%{manufacturer_auxiliary2}", dc.value("manufacturer_auxiliary2").toString()); str.replace("%{manufacturer_reference_auxiliary2}", dc.value("manufacturer_reference_auxiliary2").toString()); + str.replace("%{machine_manufacturer_reference_auxiliary2}", dc.value("machine_manufacturer_reference_auxiliary2").toString()); str.replace("%{supplier_auxiliary2}", dc.value("supplier_auxiliary2").toString()); str.replace("%{quantity_auxiliary2}", dc.value("quantity_auxiliary2").toString()); str.replace("%{unity_auxiliary2}", dc.value("unity_auxiliary2").toString()); @@ -323,6 +325,7 @@ namespace autonum str.replace("%{designation_auxiliary3}", dc.value("designation_auxiliary3").toString()); str.replace("%{manufacturer_auxiliary3}", dc.value("manufacturer_auxiliary3").toString()); str.replace("%{manufacturer_reference_auxiliary3}", dc.value("manufacturer_reference_auxiliary3").toString()); + str.replace("%{machine_manufacturer_reference_auxiliary3}", dc.value("machine_manufacturer_reference_auxiliary3").toString()); str.replace("%{supplier_auxiliary3}", dc.value("supplier_auxiliary3").toString()); str.replace("%{quantity_auxiliary3}", dc.value("quantity_auxiliary3").toString()); str.replace("%{unity_auxiliary3}", dc.value("unity_auxiliary3").toString()); @@ -333,6 +336,7 @@ namespace autonum str.replace("%{designation_auxiliary4}", dc.value("designation_auxiliary4").toString()); str.replace("%{manufacturer_auxiliary4}", dc.value("manufacturer_auxiliary4").toString()); str.replace("%{manufacturer_reference_auxiliary4}", dc.value("manufacturer_reference_auxiliary4").toString()); + str.replace("%{machine_manufacturer_reference_auxiliary4}", dc.value("machine_manufacturer_reference_auxiliary4").toString()); str.replace("%{supplier_auxiliary4}", dc.value("supplier_auxiliary4").toString()); str.replace("%{quantity_auxiliary4}", dc.value("quantity_auxiliary4").toString()); str.replace("%{unity_auxiliary4}", dc.value("unity_auxiliary4").toString()); diff --git a/tests/qttest/fixtures/aux_machine_reference.qet b/tests/qttest/fixtures/aux_machine_reference.qet new file mode 100644 index 000000000..5803b63b5 --- /dev/null +++ b/tests/qttest/fixtures/aux_machine_reference.qet @@ -0,0 +1,270 @@ + + + 10/2/26 + 02-10-2026 + 2026-10-02 + skeleton + /tmp/qet-mcp-new-2fmbrnvi/skeleton.qet + 19:29 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + MMR-AUX1 + MMR-AUX2 + MMR-AUX3 + MMR-AUX4 + MR-AUX1 + MR-AUX2 + MR-AUX3 + MR-AUX4 + + + + + + + + label + + + [%{machine_manufacturer_reference_auxiliary1}|MR-AUX1] + [%{machine_manufacturer_reference_auxiliary1}|%{manufacturer_reference_auxiliary1}] + + + [%{machine_manufacturer_reference_auxiliary2}|MR-AUX2] + [%{machine_manufacturer_reference_auxiliary2}|%{manufacturer_reference_auxiliary2}] + + + [%{machine_manufacturer_reference_auxiliary3}|MR-AUX3] + [%{machine_manufacturer_reference_auxiliary3}|%{manufacturer_reference_auxiliary3}] + + + [%{machine_manufacturer_reference_auxiliary4}|MR-AUX4] + [%{machine_manufacturer_reference_auxiliary4}|%{manufacturer_reference_auxiliary4}] + + + + + + + + + + Elements importats + Zavedené prvky + Importerede elementer + Importierte Elemente + Εισηγμένα στοιχεία + Imported elements + Elementos importados + Éléments importés + Uvezeni elementi + Elementi importati + インバートされた要素 + 전기 심볼 요소 + 전기 심볼 요소 + Elementen geïmporteerd + Elementen geïmporteerd + Elementy importowane + Elementos importados + Elementos importados + Elemente importate + Импортированные элементы + Uvoženi elementi + Importerade element + İthal öğeler + Імпортовані елементи + 导入元件 + + + + كهربائي + Elèctric + Elektrotechnika + Elektrisk + Elektrik + Ηλεκτρικά + Electric + Eléctrica + Sähkö + Electrique + Električno + Elektromos + Elettrica + 電気 + 전기 + Цахилгаан + Elektrisk + Elektrotechniek + Elektrisch + Elektrotechnika + Elétrico + Elétrica + Electric + Электротехника + Elektrické + Elektrika + Електрика + El + Elektrik + Електрика + 10_电气 + 电气工程 + + + + متعدد الأقطاب + Multifilar + Vícežilový + Flere ledere + Allpolig + Πολυγραμμικό + All-pole + Multifilar + Yleisnapa + Multifilaire + Univerzalni + Többvonalas szimbólumok + Multifilare + 複線 + 다-극 + Бүх туйл + Alle poler + Veel polig + All-pole + Schematy wieloliniowe + Multipolar + Multifilar + Bipolar + Многополюсные + Všepólové + Vsi poli + Свe-полни + Allpolig + Çok kutuplu + Багатополюсні + 10_全极 + + + + طرفيات توصيل + Borns i regletes de borns + Svorky + Klemmer og klemmerækker + Klemmen und Klemmleisten + Ακροδέκτες και σειρές ακροδεκτών + Terminals and terminal strips + Terminales + Rimaelittimet + Bornes et borniers + Stezaljke i redne stezaljke + Sorkapcsok + Terminali + 端子と端子台 + 단자 및 단자대 + Клемм ба клеммын хавтан + Rekkeklemmer og klemlister + Klemmenlijst + Klemmen en klemmenstroken + Złącza i zaciski + Terminais + Bornes e borneiras + Borne și borniere + Клеммы и клеммники + Svorky a svorkovnice + Vrstne sponke in sponke + Клеме и редне клеме + Plintar och plintrader + Klemensler ve klemens şeritleri + Клеми та клемні колодки + 接线端子与端子排 + + + + + + طرف توصيل + Born de continuïtat + Spojovací svorka + Klemme + Klemme + Ακροδέκτης + Terminal block + Terminal de unión + Liitinrima + Borne continuité + Stezaljka + Sorkapocs + Terminale di unione + 端子ブロック + 단자 블록 + Клеммын блок + Rekkeklemme + klem doorgang + Klemmenblok + Zacisk + Terminal de combinação + Borne de combinacao + Bloc de borne + Клеммное соединение + Svorkovnica + Vrstna sponka + Клемни блок + Plint + Klemens bloğu + Клемна колодка + 2号接线端子 + + + generic + generic + + Author: The QElectroTech team +License: see http://qelectrotech.org/wiki/doc/elements_license + + + + + + + + label + + + + + + + + + + + + + diff --git a/tests/qttest/tst_resaveunchanged.cpp b/tests/qttest/tst_resaveunchanged.cpp index 252457dd3..042a934d6 100644 --- a/tests/qttest/tst_resaveunchanged.cpp +++ b/tests/qttest/tst_resaveunchanged.cpp @@ -98,6 +98,26 @@ private slots: QVERIFY2(read(first) == read(second), "the second save changed the file"); } + // %{machine_manufacturer_reference_auxiliary1..4} resolve like their + // neighbours: they were missing from AssignVariables::replaceVariable() + // and printed as literal text. The fixture has one terminal whose + // four texts are "[%{machine_..._auxiliaryN}|%{manufacturer_reference_auxiliaryN}]", + // saved by a build without the fix, so the literal text is in the file. + void auxiliaryMachineReferenceResolves() + { + const QString fixture = QFINDTESTDATA("fixtures/aux_machine_reference.qet"); + QVERIFY(!fixture.isEmpty()); + const QString saved = resave(fixture); + QVERIFY2(!saved.isEmpty(), "--resave failed"); + const QString xml = QString::fromUtf8(read(saved)); + for (int n = 1; n <= 4; ++n) { + const QString shown = QStringLiteral("[MMR-AUX%1|MR-AUX%1]").arg(n); + QVERIFY2(xml.contains(shown), qPrintable(shown + QStringLiteral(" not in the saved file"))); + } + QVERIFY2(!xml.contains(QStringLiteral("[%{machine")), + "a machine manufacturer reference variable was left unresolved"); + } + // 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()