Details
-
Bug
-
Resolution: Fixed
-
P2: Important
-
6.4.1
-
41248f259 (dev)
Description
We have:
- 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.
- 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().
- 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:
- 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.
- Allocate storage for a type given by QMetaType on the heap, but don't construct. Same as above.
- Create a QVariant with adequate storage for a type given by QMetaType, using QVariant's storage size rules but don't construct the type.
- Construct a type given by QMetaObject into a pre-allocated piece of storage, using a specific Q_INVOKABLE constructor with specific arguments.
- Move-construct a type given by QMetaType and a piece of "source" storage into a pre-allocated piece of "target" storage.
- Move-assign a type given by QMetaType from one piece of storage to another.
- 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
- resulted from
-
QTBUG-108789 completing the concept of QQmlValueTypeProvider::createValueType
- Closed
For Gerrit Dashboard: QTBUG-108879 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
457324,5 | moc: Allow calling ctors on pre-allocated data | dev | qt/qtbase | Status: MERGED | +2 | 0 |