Details
-
Suggestion
-
Resolution: Unresolved
-
P4: Low
-
None
-
None
-
None
Description
I believe that Qt::UniqueConnection should be the default type of connection. Ideally, it should assert in DEBUG if a connection is not unique.
The reason is that during more than 10 years of using Qt, I have not yet seen any single use case where multiple connection between one pair of signal and slot would be desirable. On the other hand I have already seen many examples where wrong code resulted in multiplying connections (kind of "connection leakage") which caused bad performance and sometimes a very hard-to-catch errors. Therefore it is crucial to catch these errors as soon as possible.
So I think that unique connection should be the default and should be asserted in DEBUG. Multiple connections should be allowed, but only via the optional flag, e.g. something like Qt::MultiConnection.
I believe that enforcing unique connection by default should be possible for signal -> slot connection. I am not sure though if this is possible for signal -> lambda or signal -> free function connections... Maybe experts could tell.
I know this is a breaking change, possible only when code compatibility is not strictly kept, maybe when transitioning from Qt6 to Qt7.