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

QMetaMethod::invoke() does not properly check QObject pointers for compatibility anymore

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P2: Important P2: Important
    • None
    • 6.5.0 FF
    • Core: Object Model
    • None

      Considering a slot Foo::bar(SomeQObject*), QMetaMethod::invoke() cannot call this with a QGenericArgument of type QObject* anymore, even though the QObject* in question actually has the correct type.

      This has worked before and is a regression in Qt 6.5. The regression has been introduced by commit a1c34d8bd09bfc6e80dcb06c7900d40c2d32518c ("QMetaObject: rewrite QMetaMethod::invoke") in qtbase. This causes autotests in QtWebChannel to fail. See QTBUG-105596 in particular:

      QWARN  : TestWebChannel::testPassWrappedObjectBack() QMetaMethod::invoke: cannot convert formal parameter 0 from QObject* in call to TestObject::setReturnedObject(TestObject*)
      FAIL!  : TestWebChannel::testPassWrappedObjectBack() Compared QObject pointers are not the same
         Actual   (registeredObj.mReturnedObject): <null>
         Expected (&returnedObjMethod)           : TestObject/0x7ffdd386cd50
         Loc: [../qtwebchannel/tests/auto/webchannel/tst_webchannel.cpp(916)]
      

      Is this behavior intended? The documentation makes no guarantees about implicitly converting QObject* pointers. Considering that we hit this in one of our own modules, I'd say it's likely that user code will be affected as well.

        For Gerrit Dashboard: QTBUG-105616
        # Subject Branch Project Status CR V

            thiago Thiago Macieira
            msarehn Arno Rehn
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:

                There are no open Gerrit changes