Terminal: pass the voltage across a separation only when it was edited

The three code paths that copied the voltage / protocol to the far
side of a function separated terminal -- the conductor properties
dialog, search/replace and the script API -- compared it against the
far wire's own properties instead of against the edit itself. The two
sides differ on that field just as often as not, so the comparison
held no matter what was edited and every change overwrote the far
side's voltage: setting a colour on a 24 V side dragged the 0 V one
along, where master left it alone. Compare the edit -- what the
dialog was filled with against what the user made of it -- so that a
change of the voltage / protocol is what crosses, which is what the
selection panel multi-edit already did. The values are read before
the undo commands are pushed, since QPropertyUndoCommand applies on
push.

An explicitly selected wire is never the far side of anything:
picking one wire on each side of a separation and editing them edits
them both, in full, however the selection happens to be walked. Nor
is a wire that belongs to a potential on any path, so reaching it
once normally and once across a separation gives it the full edit.
This commit is contained in:
Kellermorph
2026-10-13 20:13:18 +02:00
parent 561ddc29bf
commit 408ef5114d
6 changed files with 170 additions and 18 deletions
@@ -226,9 +226,12 @@ void SearchAndReplaceWorker::replaceConductor(QList<Conductor *> list)
project_->undoStack()->beginMacro(QObject::tr("Search / replace conductors properties."));
for (Conductor *c : list)
{
ConductorProperties cp = applyChange(c->properties(), m_conductor_properties);
//Captured before the pushes below: QPropertyUndoCommand applies
//on push, so reading it afterwards would give back @a cp.
const ConductorProperties old_properties = c->properties();
ConductorProperties cp = applyChange(old_properties, m_conductor_properties);
if (cp != c->properties())
if (cp != old_properties)
{
QSet <Conductor *> conductors_list = c->relatedPotentialConductors(true);
conductors_list << c;
@@ -241,12 +244,16 @@ void SearchAndReplaceWorker::replaceConductor(QList<Conductor *> list)
}
//The other side of a function separated terminal element
//only receives the voltage / protocol (@see
//only receives the voltage / protocol, and only when this
//replacement really changed it: the comparison is this
//replacement's own before / after (@a old_properties vs
//@a cp), never the far wire's own value, which would make
//every replacement overwrite it (@see
//Conductor::functionSeparatedConductors).
for (Conductor *cc : c->functionSeparatedConductors(true))
{
ConductorProperties separated_cp = cc->properties();
separated_cp.applyTensionProtocolChange(cc->properties(), cp);
separated_cp.applyTensionProtocolChange(old_properties, cp);
if (separated_cp == cc->properties())
continue;
@@ -369,12 +376,15 @@ void SearchAndReplaceWorker::replaceAdvanced(
}
//The other side of a function separated terminal element
//only receives the voltage / protocol (@see
//only receives the voltage / protocol, and only when
//this replacement really changed it: the comparison is
//this replacement's own before / after, never the far
//wire's own value (@see
//Conductor::functionSeparatedConductors).
for (Conductor *c : conductor->functionSeparatedConductors(true))
{
ConductorProperties separated_properties = c->properties();
separated_properties.applyTensionProtocolChange(c->properties(), new_properties);
separated_properties.applyTensionProtocolChange(old_properties, new_properties);
if (separated_properties == c->properties())
continue;