Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qqmltcobjectcreationhelper.cpp
Go to the documentation of this file.
1// Copyright (C) 2022 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
5
6#include <private/qqmlmetatype_p.h>
7#include <private/qmetaobjectbuilder_p.h>
8#include <private/qobject_p.h>
9#include <private/qqmltype_p_p.h>
10
12
14{
15 // TODO: when/if qmltc-compiled types would be registered via
16 // qmltyperegistrar, instead of creating a dummy QQmlTypePrivate, fetch the
17 // good QQmlType via QQmlMetaType::qmlType(). to do it correctly, one needs,
18 // along with the meta object, module name and revision. all that should be
19 // available ahead-of-time to qmltc.
20 auto qmlTypePrivate = new QQmlTypePrivate(data.regType);
21
22 // tie qmlTypePrivate destruction to objects's destruction. the type's
23 // content is not needed once the associated object is deleted
24 QObject::connect(object, &QObject::destroyed, object,
25 [qmlTypePrivate](QObject *) { qmlTypePrivate->release(); },
27
28 // initialize QQmlType::QQmlCppTypeData
30 qmlTypePrivate->extraData.cppTypeData->allocationSize = data.allocationSize;
31 qmlTypePrivate->extraData.cppTypeData->newFunc = nullptr;
32 qmlTypePrivate->extraData.cppTypeData->userdata = nullptr;
33 qmlTypePrivate->extraData.cppTypeData->noCreationReason =
34 QStringLiteral("Qmltc-compiled type is not creatable via QQmlType");
35 qmlTypePrivate->extraData.cppTypeData->createValueTypeFunc = nullptr;
36 qmlTypePrivate->extraData.cppTypeData->parserStatusCast = -1;
37 qmlTypePrivate->extraData.cppTypeData->extFunc = nullptr;
38 qmlTypePrivate->extraData.cppTypeData->extMetaObject = nullptr;
39 qmlTypePrivate->extraData.cppTypeData->customParser = nullptr;
40 qmlTypePrivate->extraData.cppTypeData->attachedPropertiesFunc = nullptr;
41 qmlTypePrivate->extraData.cppTypeData->attachedPropertiesType = nullptr;
42 qmlTypePrivate->extraData.cppTypeData->propertyValueSourceCast = -1;
43 qmlTypePrivate->extraData.cppTypeData->propertyValueInterceptorCast = -1;
44 qmlTypePrivate->extraData.cppTypeData->finalizerCast = -1;
45 qmlTypePrivate->extraData.cppTypeData->registerEnumClassesUnscoped = false;
46 qmlTypePrivate->extraData.cppTypeData->registerEnumsFromRelatedTypes = false;
47
48 qmlTypePrivate->baseMetaObject = data.metaObject;
49
50 QQmlType qmlType(qmlTypePrivate);
51 Q_ASSERT(qmlType.isValid());
52
54 // ### inefficient - rather, call this function only once for the leaf type
55 if (op->metaObject) {
56 delete op->metaObject;
57 op->metaObject = nullptr;
58 }
59
60 qmlType.createProxy(object);
61}
62
QDynamicMetaObjectData * metaObject
Definition qobject.h:90
static QObjectPrivate * get(QObject *o)
Definition qobject_p.h:150
\inmodule QtCore
Definition qobject.h:103
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
Definition qobject.cpp:2960
void destroyed(QObject *=nullptr)
This signal is emitted immediately before the object obj is destroyed, after any instances of QPointe...
void createProxy(QObject *instance) const
Definition qqmltype.cpp:831
bool isValid() const
Definition qqmltype_p.h:54
Combined button and popup list for selecting options.
@ DirectConnection
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
QT_BEGIN_NAMESPACE void qmltcCreateDynamicMetaObject(QObject *object, const QmltcTypeData &data)
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
#define QStringLiteral(str)