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

Ensure qml type attributes (attached, singleton, etc.) do not leak into derived types in C++

    XMLWordPrintable

Details

    Description

      QML has multiple declarative macros like QML_ATTACHED, QML_SINGLETON, QML_EXTENDED and so on. These work by adding special member variables and type aliases to the enclosing type where the macro is used.
      Later on, we could use these member variables and type aliases to detect whether a specific C++ type has a certain QML attribute (e.g. whether it has an attached type or whether it is a singleton, etc.) at compile time. This is vital information for C++ -> QML type registration.

      The problem with the current approach is that member variable and type aliases "leak" into derived C++ type, so that:

      class X {
        QML_ATTACHED(T) // adds "using QmlAttachedType = U;" and other stuff
      };
      
      class Y : public X {}; // Y::QmlAttachedType exists because X::QmlAttachedType exists
      

      To avoid this, a somewhat generic idea was introduced in [1], however we still lack changes that would correctly handle the information added by [1]. Thus, we have to do it for all the attributes of interest. [2] already does so for extended types and could be used as an example.

      [1]: 560a47590fc0c22c18ca91fee56176e2501561f6
      [2]: cfbc5ecf2af04e4c0ae6053081b2fa47e8ac5ca8

      Attachments

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

        Activity

          People

            sami.shalayel Sami Shalayel
            agolubev Andrei Golubev
            Alex Blasche Alex Blasche
            Vladimir Minenko Vladimir Minenko
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes