mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-10-01 23:54:13 +02:00
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 <noreply@anthropic.com>
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user