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

Constructing, copying and moving objects using QVariant/QMetaType/QMetaObject is incomplete

    XMLWordPrintable

Details

    • 41248f259 (dev)

    Description

      We have:

      1. QVariant. You can pass it a QMetaType as constructor argument. It then allocates (or uses its internal space) and default-constructs an instance of the given type.
      2. QMetaType: You get to default-construct or copy-construct the given type, either with allocation or into a given piece of storage using construct() or create().
      3. QMetaObject: There is a CreateInstance metacall that can invoke an arbitrary Q_INVOKABLE constructor, but always creates the instance in a newly allocated piece of heap storage.

      What I need is:

      1. Allocate storage for a type given by QMetaType on the stack, but don't construct. I can do that with alloca() and QMetaType::sizeOf(), but it's not pretty. I'm not sure if this is realistic, but it sure would be nice to find a better abstraction here.
      2. Allocate storage for a type given by QMetaType on the heap, but don't construct. Same as above.
      3. Create a QVariant with adequate storage for a type given by QMetaType, using QVariant's storage size rules but don't construct the type.
      4. Construct a type given by QMetaObject into a pre-allocated piece of storage, using a specific Q_INVOKABLE constructor with specific arguments.
      5. Move-construct a type given by QMetaType and a piece of "source" storage into a pre-allocated piece of "target" storage.
      6. Move-assign a type given by QMetaType from one piece of storage to another.
      7. Copy-assign a type given by QMetaType from one piece of storage to another.

      Not having those capabilities requires me to unnecessarily create, destruct, and copy values in order to get them to the places where I need them.

      Attachments

        Issue Links

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

          Activity

            People

              ulherman Ulf Hermann
              ulherman Ulf Hermann
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes