Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-102741

Qt::UniqueConnection should be the default type of connection

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Unresolved
    • P4: Low
    • None
    • None
    • Core: Object Model
    • 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.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            thiago Thiago Macieira
            vladimir.kraus Vladimir Kraus
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes