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

QObject::connect should warn for self-connects

    XMLWordPrintable

Details

    Description

      If code, due user copy/paste error, ends up connecting a signal to itself rather than to the source signal that is actually emitted, then it is hard to find out what went wrong. I.e.

      connect(this, SIGNAL(mySignal()), this, SIGNAL(mySignal()));

      instead of

      connect(sender, SIGNAL(mySignal()), this, SIGNAL(mySignal()));

      where only sender emits the signal.

      Since the incorrect connect is always invalid (it crashes with stack overflow if "this" emits the signal), Qt should warn about such a connecting.

      Comment: Qt shouldn't check this at run time - spending CPU cycles in a performance critical part of Qt to check for a condition that never happens in valid code is not a good idea. We should make moc check for this at compile time instead.

      Attachments

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

        Activity

          People

            goffart Olivier Goffart (closed Nokia identity) (Inactive)
            vhilshei Volker Hilsheimer
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes