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

qmetamethod invoke changed source-incompatible way

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 6.5
    • Core: Object Model
    • None
    • Linux/X11

    Description

      Last year I had a lot of fun writing a scripting language and interpreter in Qt.
      There are callbacks to known QObject based tool classes and the binding is done using the meta object system from Qt.

      After upgrading to Qt6.5, it stopped compiling.

      Seems that the Q_RETURN_ARG has been changed in a source incompatible manner.
      Same with the Q_ARG macro.

      I guess that the idea was that since the only place this method could be used was in methods like QMetaMethod::invoke(), just providing new methods with the new arguments would be enough.
      And from a binary compatibility point of view this is correct. But not from a source-compatibility point of view.

      Not sure if I missed the memo if its Ok to break source compatibility between minor releases. It still feels like this porting can use a lot more love.

      The usecase that broke, and as far as I can tell has now become impossible to do:

      I have an script-interpreter. The interpreter allows the user to call methods on QObjects with the only requirement that all arguments are strings. And the return value is something like an int or a bool.

      Code snippet can be read on https://forum.qt.io/topic/145618/qmetamethod-how-to-use-after-the-changes

      Specific bugs;

      • Q_ARG no longer creates a QGenericArgument. The QGenericArgument class does not have a constructor I can use. Meaning that I can no longer create QGenericArgument instances.
      • Ditto for Q_RETURN_ARG and QGenericReturnArgument
      • Calling the deprecated method invoke() with QMetaMethodReturnArgument and 10 QMetaMethodArgument arguments crashes in Qt.
      • the new invoke() methods fail if the return type is void AND the QMetaMethodReturnArgument is invalid (default constructor). Meaning I have to call the invoke differently if there is no return argument.

      I tried to port all to the new classes and ended up with something like;

      { QMetaMethodArgument qArgs[10]; bool ok = method.invoke(context, Qt::DirectConnection, rc, qArgs); }

      This always returns false.

      I don't know how to pass in a variable number of arguments into a variadic list.

      Can Qt please again support the usecase of calling a method where at compile time we do NOT know the number of arguments?

      Bottom line; a meta data system that requires me to write tons of different ways to call invoke dynamically based on different arguments and return types is missing the fact that not knowing the arguments and return types at compile time is the entire point of having a meta data system.

      Attachments

        Issue Links

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

          Activity

            People

              thiago Thiago Macieira
              tomz Tom Zander
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There is 1 open Gerrit change