mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-10-08 04:44:13 +02:00
Revert the isFull() change: max_slaves counts slots, not contacts
The earlier commit changed MasterElement::isFull() to compare the contacts in use against max_slaves. That was wrong, and this restores the original comparison against the number of linked elements. max_slaves is a number of slots, not of contacts: - it sizes the contact group table in the element editor, one row per slot (ElementPropertiesEditorWidget::populateSlaveGroupsTable) - a group must match the slave's own contact count before it can be chosen, so a 4 pole slave needs a group declaring 4 and occupies that single group (ContactGroupSelectionDialog) - each slave stores exactly one group index (Element::setGroupIndexForElement) So a coil declaring 4 slots accepts 4 slaves, whatever their pole count. Counting contacts made one 4 pole slave fill a 4 slot coil on its own and refuse three further links that should have been allowed. ContactUsage stays, and its per-type tally is still what the General tab needs: how many contacts an auxiliary block must provide is a different question from how many slots are occupied, and only the former wants the pole multiplier. The header now says so. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -29,6 +29,12 @@
|
||||
rules can be unit tested on their own. MasterElement::contactUsage()
|
||||
is the thin wrapper that feeds it the linked elements.
|
||||
|
||||
This counts contacts, which is what tells you how many contacts an
|
||||
auxiliary block must provide. It is deliberately not the count that
|
||||
MasterElement::isFull() uses: a master's max_slaves is a number of
|
||||
slots, and a slave fills exactly one slot however many contacts it
|
||||
carries.
|
||||
|
||||
Two rules are easy to get wrong, and both live here so that every
|
||||
caller gets them right:
|
||||
- a slave stands for as many contacts as its "number" kind
|
||||
|
||||
@@ -282,8 +282,11 @@ bool MasterElement::isFull() const
|
||||
return false;
|
||||
}
|
||||
|
||||
// Return true if the contacts already used reached or exceeded the limit
|
||||
return contactUsage().total() >= max_slaves;
|
||||
// max_slaves is a number of slots, not of contacts: it sizes the
|
||||
// element's contact group table, and a slave occupies exactly one
|
||||
// group however many contacts that group stands for. So the slots
|
||||
// in use are the linked elements, not the contacts they carry.
|
||||
return connected_elements.size() >= max_slaves;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user