diff --git a/sources/contactusage.h b/sources/contactusage.h index 5b29176ca..406a6223a 100644 --- a/sources/contactusage.h +++ b/sources/contactusage.h @@ -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 diff --git a/sources/qetgraphicsitem/masterelement.cpp b/sources/qetgraphicsitem/masterelement.cpp index 1ccebfd3a..599b8c90d 100644 --- a/sources/qetgraphicsitem/masterelement.cpp +++ b/sources/qetgraphicsitem/masterelement.cpp @@ -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; } /**