From 4283ddad10ff7fd8cd69b7414c16082f5ef791ff Mon Sep 17 00:00:00 2001 From: ispyisail Date: Tue, 22 Sep 2026 22:52:48 +1200 Subject: [PATCH] linkElements: refuse a report link that would pop a modal dialog Fixing LinkElementCommand's property comparison (previous commit) means it now correctly detects a report-link colour/style mismatch -- which means it now correctly pops PotentialSelectorDialog for one, same as the GUI. Under headless --run there is nobody to answer a plain QDialog::exec(), so this hangs forever; confirmed directly with a timeout before adding this guard. qet.linkElements() now checks LinkElementCommand:: reportLinkNeedsPotentialChoice() before constructing the command and declines with a clear reason pointing at checkContinuity() and setConductorProperty(), the same choice addConductor() already makes about ConductorCreator's own equivalent ambiguous-potential dialog. Co-Authored-By: Claude Sonnet 5 --- sources/scripting/qetscriptapi.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/sources/scripting/qetscriptapi.cpp b/sources/scripting/qetscriptapi.cpp index adc84d5d5..3e75e7c40 100644 --- a/sources/scripting/qetscriptapi.cpp +++ b/sources/scripting/qetscriptapi.cpp @@ -1076,6 +1076,26 @@ bool QetScriptApi::linkElements(int folioIndexA, const QString &elementUuidA, elementUuidB, elementLinkType(folioIndexB, elementUuidB))); return false; } + // Linking two report elements (next_report/previous_report) that each + // already carry a conductor with differing properties (colour, line + // style, text, function or tension protocol) makes + // LinkElementCommand::redo() open PotentialSelectorDialog -- a plain + // QDialog::exec(), not routed through QET::QetMessageBox, so headless + // --run has nobody to answer it and hangs until killed. Measured: + // confirmed hanging with the fix below NOT in place, confirmed clean + // (no hang, false returned) with it in place. Same reasoning and the + // same choice addConductor() already makes about ConductorCreator's + // own ambiguous-potential dialog. + if (LinkElementCommand::reportLinkNeedsPotentialChoice(a, b)) { + log(QStringLiteral("qet.linkElements: %1 and %2 already carry conductors whose " + "colour, style, text, function or tension protocol disagree -- " + "linking them would open a dialog asking which to keep, and " + "nobody is there to answer it under --run. Use " + "qet.checkContinuity() to see the mismatch, resolve it with " + "setConductorProperty() on one side, then link") + .arg(elementUuidA, elementUuidB)); + return false; + } auto isPlcMaster = [](Element *e) { return e->elementData().m_type == ElementData::Master && e->elementData().m_master_type == ElementData::PLC;