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

QObject::disconnect accepts const Connection reference but mutates it

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P2: Important P2: Important
    • None
    • 5.9.6, 5.11.0
    • Core: Object Model
    • None

      The function:
      static bool QObject::disconnect(const QMetaObject::Connection &connection)

      accepts const reference to QMetaObject::Connection but modifies it at line:
      const_cast<QMetaObject::Connection &>(connection).d_ptr = 0;

      Semantically it's wrong, because the QMetaObject is modified and also responds to query as not being connected after the call, so the function should have non-const reference parameter.
      This disconnect function was introduced in Qt 5.0.0 but the implementation with const_cast has been changed on Qt 5.0.1.

      I assume an overloaded function should have been provided instead and existing one marked as deprecated not to break binary compatibility.

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

            Unassigned Unassigned
            pavol.markovic Pavol Markovic
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:

                There are no open Gerrit changes