14#include <private/qqmljavascriptexpression_p.h>
15#include <private/qqmlsourcecoordinate_p.h>
17#include <private/qv4functionobject_p.h>
18#include <private/qv4script_p.h>
19#include <private/qv4scopedvalue_p.h>
20#include <private/qv4objectiterator_p.h>
21#include <private/qv4qobjectwrapper_p.h>
22#include <private/qv4jscall_p.h>
27#include <QThreadStorage>
28#include <QtCore/qdebug.h>
29#include <QtCore/qloggingcategory.h>
33using namespace Qt::Literals::StringLiterals;
36 Q_CONSTINIT
thread_local int creationDepth = 0;
43class QQmlComponentExtension :
public QV4::ExecutionEngine::Deletable
46 QQmlComponentExtension(QV4::ExecutionEngine *v4);
47 virtual ~QQmlComponentExtension();
49 QV4::PersistentValue incubationProto;
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
272
273
274
275
276
277
278
279
280
283
284
285
286
287
288
289
290
292void QQmlComponentPrivate::ready(QQmlNotifyingBlob *)
296 Q_ASSERT(m_typeData);
298 fromTypeData(m_typeData);
301 emit q->statusChanged(q->status());
304void QQmlComponentPrivate::progress(QQmlNotifyingBlob *, qreal p)
309void QQmlComponentPrivate::fromTypeData(
const QQmlRefPointer<QQmlTypeData> &data)
311 m_url = data->finalUrl();
312 if (
auto cu = data->compilationUnit())
313 m_compilationUnit = m_engine->handle()->executableCompilationUnit(std::move(cu));
315 if (!m_compilationUnit) {
316 Q_ASSERT(data->isError());
317 m_state.errors.clear();
318 m_state.appendErrors(data->errors());
322bool QQmlComponentPrivate::hadTopLevelRequiredProperties()
const
324 return m_state.creator()->componentHadTopLevelRequiredProperties();
327void QQmlComponentPrivate::clear()
330 m_typeData->unregisterCallback(
this);
335 m_loadHelper->unregisterCallback(
this);
336 m_loadHelper.reset();
339 m_compilationUnit.reset();
340 m_inlineComponentName.reset();
343QObject *QQmlComponentPrivate::doBeginCreate(QQmlComponent *q, QQmlContext *context)
347 qWarning(
"QQmlComponent: Must provide an engine before calling create");
351 context = m_engine->rootContext();
352 return q->beginCreate(context);
356 QV4::Value *object,
const QString &propertyName,
const QQmlObjectCreator *creator)
361 QV4::QObjectWrapper *wrapper = object->as<QV4::QObjectWrapper>();
365 QObject *o = wrapper->object();
369 if (QQmlData *ddata = QQmlData::get(o)) {
371 propertyName, o, ddata->outerContext);
372 if (propData && propData->acceptsQBinding())
373 creator->removePendingBinding(o, propData->coreIndex());
377 const QMetaObject *meta = o->metaObject();
379 const int index = meta->indexOfProperty(propertyName.toUtf8());
380 if (index != -1 && meta->property(index).isBindable())
381 creator->removePendingBinding(o, index);
384bool QQmlComponentPrivate::setInitialProperty(
385 QObject *base,
const QString &name,
const QVariant &value)
387 bool isComplexProperty = name.contains(u'.');
390 if (m_state.hasUnsetRequiredProperties() && !isComplexProperty)
391 prop = QQmlComponentPrivate::removePropertyFromRequired(
392 base, name, m_state.requiredProperties(), m_engine);
393 else if (QQmlContext *ctxt = qmlContext(base); ctxt)
394 prop = QQmlProperty(base, name, ctxt);
396 prop = QQmlProperty(base, name, m_engine);
397 const bool isValid = prop.isValid();
398 if (!isValid && isComplexProperty) {
400 const QStringList properties = name.split(u'.');
401 QV4::Scope scope(m_engine->handle());
402 QV4::ScopedObject object(scope, QV4::QObjectWrapper::wrap(scope.engine, base));
403 QV4::ScopedString segment(scope);
404 for (
int i = 0; i < properties.size() - 1; ++i) {
405 segment = scope.engine->newString(properties.at(i));
406 object = object->get(segment);
407 if (scope.engine->hasException || object->isNullOrUndefined())
410 const QString lastProperty = properties.last();
411 if (!object->isNullOrUndefined()) {
412 segment = scope.engine->newString(lastProperty);
413 QV4::ScopedValue v(scope, scope.engine->metaTypeToJS(value.metaType(), value.constData()));
414 object->put(segment, v);
418 if (scope.engine->hasException) {
419 qmlWarning(base, scope.engine->catchExceptionAsQmlError());
420 scope.engine->hasException =
false;
423 removePendingQPropertyBinding(object, lastProperty, m_state.creator());
426 QQmlPropertyPrivate *privProp = QQmlPropertyPrivate::get(prop);
427 if (isValid && privProp->writeValueProperty(value, {})) {
428 if (prop.isBindable()) {
429 if (QQmlObjectCreator *creator = m_state.creator())
430 creator->removePendingBinding(prop.object(), prop.index());
436 error.setDescription(QStringLiteral(
"Could not set initial property %1").arg(name));
438 error.setDescription(QStringLiteral(
"Setting initial properties failed: "
439 "%2 does not have a property called %1")
440 .arg(name, QQmlMetaType::prettyTypeName(base)));
442 qmlWarning(base, error);
451
452
453QQmlComponent::QQmlComponent(QObject *parent)
454 : QObject(*(
new QQmlComponentPrivate), parent)
459
460
461QQmlComponent::~QQmlComponent()
465 if (d->m_state.isCompletePending()) {
466 qWarning(
"QQmlComponent: Component destroyed while completion pending");
469 qWarning() <<
"This may have been caused by one of the following errors:";
470 for (
const QQmlComponentPrivate::AnnotatedQmlError &e : std::as_const(d->m_state.errors))
471 qWarning().nospace().noquote() << QLatin1String(
" ") << e.error;
475 if (d->m_state.hasCreator())
480 d->m_typeData->unregisterCallback(d);
481 if (d->m_engine && !d->m_typeData->isCompleteOrError()) {
484 QQmlTypeLoader::get(d->m_engine)->drop(QQmlDataBlob::Ptr(d->m_typeData.data()));
486 d->m_typeData.reset();
491
492
493
494
495
496
497
498
499
500
501
504
505
506
507QQmlComponent::Status QQmlComponent::status()
const
509 Q_D(
const QQmlComponent);
513 else if (!d->m_state.errors.isEmpty())
515 else if (d->m_engine && (d->m_compilationUnit || d->loadedType().isValid()))
517 else if (d->m_loadHelper)
524
525
526bool QQmlComponent::isNull()
const
528 return status() == Null;
532
533
534bool QQmlComponent::isReady()
const
536 return status() == Ready;
540
541
542bool QQmlComponent::isError()
const
544 return status() == Error;
548
549
550bool QQmlComponent::isLoading()
const
552 return status() == Loading;
556
557
558
559
560
561bool QQmlComponent::isBound()
const
563 Q_D(
const QQmlComponent);
568
569
570
571
574
575
576
577
578qreal QQmlComponent::progress()
const
580 Q_D(
const QQmlComponent);
581 return d->m_progress;
585
586
587
588
589
592
593
594
595
596
599
600
601
602QQmlComponent::QQmlComponent(QQmlEngine *engine, QObject *parent)
603 : QObject(*(
new QQmlComponentPrivate), parent)
606 d->m_engine = engine;
607 QObject::connect(engine, &QObject::destroyed,
this, [d]() {
609 d->m_engine =
nullptr;
614
615
616
617
618
619
620
621QQmlComponent::QQmlComponent(QQmlEngine *engine,
const QUrl &url, QObject *parent)
622 : QQmlComponent(engine, url, QQmlComponent::PreferSynchronous, parent)
627
628
629
630
631
632
633
634
635QQmlComponent::QQmlComponent(QQmlEngine *engine,
const QUrl &url, CompilationMode mode,
637 : QQmlComponent(engine, parent)
640 d->loadUrl(url, mode);
644
645
646
647
648
649
650
651
652QQmlComponent::QQmlComponent(QQmlEngine *engine, QAnyStringView uri, QAnyStringView typeName, QObject *parent)
653 : QQmlComponent(engine, uri, typeName, QQmlComponent::PreferSynchronous, parent)
659
660
661
662
663
664
665
666
667QQmlComponent::QQmlComponent(QQmlEngine *engine, QAnyStringView uri, QAnyStringView typeName, CompilationMode mode, QObject *parent)
668 : QQmlComponent(engine, parent)
670 loadFromModule(uri, typeName, mode);
674
675
676
677
678
679QQmlComponent::QQmlComponent(QQmlEngine *engine,
const QString &fileName,
681 : QQmlComponent(engine, fileName, QQmlComponent::PreferSynchronous, parent)
686
687
688
689
690
691
692QQmlComponent::QQmlComponent(QQmlEngine *engine,
const QString &fileName,
693 CompilationMode mode, QObject *parent)
694 : QQmlComponent(engine, parent)
697 if (fileName.startsWith(u':'))
698 d->loadUrl(QUrl(QLatin1String(
"qrc") + fileName), mode);
699 else if (QDir::isAbsolutePath(fileName))
700 d->loadUrl(QUrl::fromLocalFile(fileName), mode);
702 d->loadUrl(QUrl(fileName), mode);
706
707
708QQmlComponent::QQmlComponent(QQmlEngine *engine, QV4::ExecutableCompilationUnit *compilationUnit,
709 int start, QObject *parent)
710 : QQmlComponent(engine, parent)
713 d->m_compilationUnit.reset(compilationUnit);
715 d->m_url = compilationUnit->finalUrl();
720
721
722
723
724
725
726
727void QQmlComponent::setData(
const QByteArray &data,
const QUrl &url)
733 qWarning(
"QQmlComponent: Must provide an engine before calling setData");
741 QQmlRefPointer<QQmlTypeData> typeData = QQmlTypeLoader::get(d->m_engine)->getType(data, url);
743 if (typeData->isCompleteOrError()) {
744 d->fromTypeData(typeData);
746 d->m_typeData = typeData;
747 d->m_typeData->registerCallback(d);
751 emit statusChanged(status());
755
756
757
758QQmlContext *QQmlComponent::creationContext()
const
760 Q_D(
const QQmlComponent);
761 if (!d->m_creationContext.isNull())
762 return d->m_creationContext->asQQmlContext();
764 return qmlContext(
this);
768
769
770
771
772QQmlEngine *QQmlComponent::engine()
const
774 Q_D(
const QQmlComponent);
779
780
781
782
783void QQmlComponent::loadUrl(
const QUrl &url)
790
791
792
793
794
795void QQmlComponent::loadUrl(
const QUrl &url, QQmlComponent::CompilationMode mode)
798 d->loadUrl(url, mode);
801void QQmlComponentPrivate::loadUrl(
const QUrl &newUrl, QQmlComponent::CompilationMode mode)
806 if (newUrl.isRelative()) {
808 m_url = m_engine->baseUrl().resolved(QUrl(newUrl.toString()));
809 }
else if (m_engine->baseUrl().isLocalFile() && newUrl.isLocalFile() && !QDir::isAbsolutePath(newUrl.toLocalFile())) {
813 QUrl fixedUrl(newUrl);
814 fixedUrl.setScheme(QString());
817 m_url = m_engine->baseUrl().resolved(fixedUrl);
822 if (m_url.scheme() ==
"qrc"_L1 && !m_url.path().startsWith(
"/"_L1)) {
823 qWarning().nospace().noquote()
824 <<
"QQmlComponent: attempted to load via a relative URL '" << m_url.toString()
825 <<
"' in resource file system. This is not fully supported and may not work";
828 if (newUrl.isEmpty()) {
830 error.setDescription(QQmlComponent::tr(
"Invalid empty URL"));
831 m_state.errors.emplaceBack(error);
837 QQmlTypeLoader::Mode loaderMode = (mode == QQmlComponent::Asynchronous)
838 ? QQmlTypeLoader::Asynchronous
839 : QQmlTypeLoader::PreferSynchronous;
840 QQmlRefPointer<QQmlTypeData> data = QQmlTypeLoader::get(m_engine)->getType(m_url, loaderMode);
842 if (data->isCompleteOrError()) {
847 m_typeData->registerCallback(
this);
848 setProgress(data->progress());
851 emit q->statusChanged(q->status());
855
856
857
858QList<QQmlError> QQmlComponent::errors()
const
860 Q_D(
const QQmlComponent);
861 QList<QQmlError> errors;
862 errors.reserve(d->m_state.errors.size());
863 for (
const QQmlComponentPrivate::AnnotatedQmlError &annotated : d->m_state.errors)
864 errors.emplaceBack(annotated.error);
869
870
871
872
873
874
875
876
877
880
881
882
883QString QQmlComponent::errorString()
const
885 Q_D(
const QQmlComponent);
889 for (
const QQmlComponentPrivate::AnnotatedQmlError &annotated : d->m_state.errors) {
890 const QQmlError &e = annotated.error;
891 ret += e.url().toString() + QLatin1Char(
':') +
892 QString::number(e.line()) + QLatin1Char(
' ') +
893 e.description() + QLatin1Char(
'\n');
899
900
901
904
905
906
907
908QUrl QQmlComponent::url()
const
910 Q_D(
const QQmlComponent);
915
916
917QQmlComponent::QQmlComponent(QQmlComponentPrivate &dd, QObject *parent)
918 : QObject(dd, parent)
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938QObject *QQmlComponent::create(QQmlContext *context)
941 return d->createWithProperties(
nullptr, QVariantMap {}, context);
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964QObject *QQmlComponent::createWithInitialProperties(
const QVariantMap& initialProperties, QQmlContext *context)
967 return d->createWithProperties(
nullptr, initialProperties, context);
973
974QObject *QQmlComponentPrivate::createWithProperties(QObject *parent,
const QVariantMap &properties,
975 QQmlContext *context, CreateBehavior behavior,
980 QObject *rv = doBeginCreate(q, context);
982 if (m_state.isCompletePending()) {
986 QQmlEnginePrivate *ep = QQmlEnginePrivate::get(m_engine);
987 complete(ep, &m_state);
993 QQmlComponent_setQmlParent(rv, parent);
996 for (
auto it = properties.cbegin(), end = properties.cend(); it != end; ++it)
997 setInitialProperty(rv, it.key(), it.value());
999 q->setInitialProperties(rv, properties);
1001 q->completeCreate();
1003 if (m_state.hasUnsetRequiredProperties()) {
1004 if (behavior == CreateWarnAboutRequiredProperties) {
1005 for (
const auto &unsetRequiredProperty : std::as_const(*m_state.requiredProperties())) {
1006 const QQmlError error = unsetRequiredPropertyToQQmlError(unsetRequiredProperty);
1007 qmlWarning(rv, error);
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053QObject *QQmlComponent::beginCreate(QQmlContext *context)
1057 return d->beginCreate(QQmlContextData::get(context));
1062 const int parserStatusCast = type.parserStatusCast();
1063 return parserStatusCast == -1
1065 :
reinterpret_cast<QQmlParserStatus *>(
reinterpret_cast<
char *>(rv) + parserStatusCast);
1068QObject *QQmlComponentPrivate::beginCreate(QQmlRefPointer<QQmlContextData> context)
1071 auto cleanup = qScopeGuard([
this] {
1072 if (!m_state.errors.isEmpty() && lcQmlComponentGeneral().isDebugEnabled()) {
1073 for (
const auto &e : std::as_const(m_state.errors)) {
1074 qCDebug(lcQmlComponentGeneral) <<
"QQmlComponent: " << e.error.toString();
1079 qWarning(
"QQmlComponent: Cannot create a component in a null context");
1083 if (!context->isValid()) {
1084 qWarning(
"QQmlComponent: Cannot create a component in an invalid context");
1088 if (context->engine() != m_engine) {
1089 qWarning(
"QQmlComponent: Must create component in context from the same QQmlEngine");
1093 if (m_state.isCompletePending()) {
1094 qWarning(
"QQmlComponent: Cannot create new component instance before completing the previous");
1100 m_state.errors.removeIf([](
const auto &e) {
return e.isTransient; });
1101 m_state.clearRequiredProperties();
1103 if (!q->isReady()) {
1104 qWarning(
"QQmlComponent: Component is not ready");
1109 static const int maxCreationDepth = 10;
1110 if (creationDepth >= maxCreationDepth) {
1111 qWarning(
"QQmlComponent: Component creation is recursing - aborting");
1115 QQmlEnginePrivate *enginePriv = QQmlEnginePrivate::get(m_engine);
1117 enginePriv->inProgressCreations++;
1118 m_state.errors.clear();
1119 m_state.setCompletePending(
true);
1121 QObject *rv =
nullptr;
1123 const QQmlType type = loadedType();
1124 if (!type.isValid()) {
1125 enginePriv->referenceScarceResources();
1126 const QString *icName = m_inlineComponentName.get();
1127 m_state.initCreator(
1128 context, m_compilationUnit, m_creationContext, icName ? *icName : QString());
1130 QQmlObjectCreator::CreationFlags flags;
1132 flags = QQmlObjectCreator::InlineComponent;
1134 m_start = m_compilationUnit->inlineComponentId(*icName);
1135 Q_ASSERT(m_start > 0);
1137 flags = QQmlObjectCreator::NormalObject;
1140 rv = m_state.creator()->create(m_start,
nullptr,
nullptr, flags);
1142 m_state.appendCreatorErrors();
1143 enginePriv->dereferenceScarceResources();
1146 rv = type.createWithQQmlData();
1147 QQmlPropertyCache::ConstPtr propertyCache = QQmlData::ensurePropertyCache(rv);
1148 if (QQmlParserStatus *parserStatus = parserStatusCast(type, rv)) {
1149 parserStatus->classBegin();
1150 m_state.ensureRequiredPropertyStorage(rv);
1151 }
else if (type.finalizerCast() != -1) {
1152 m_state.ensureRequiredPropertyStorage(rv);
1155 if (propertyCache) {
1156 for (
int i = 0, propertyCount = propertyCache->propertyCount(); i < propertyCount; ++i) {
1157 if (
const QQmlPropertyData *propertyData = propertyCache->property(i); propertyData->isRequired()) {
1158 m_state.ensureRequiredPropertyStorage(rv);
1159 RequiredPropertyInfo info;
1160 info.propertyName = propertyData->name(rv);
1161 m_state.addPendingRequiredProperty(rv, propertyData, info);
1172 QQmlData *ddata = QQmlData::get(rv);
1176 ddata->indestructible =
true;
1177 ddata->explicitIndestructibleSet =
true;
1178 ddata->rootObjectInCreation =
false;
1181 if (!ddata->outerContext)
1182 ddata->outerContext = context.data();
1183 if (!ddata->context)
1184 ddata->context = context.data();
1190void QQmlComponentPrivate::beginDeferred(QQmlEnginePrivate *enginePriv,
1191 QObject *object, DeferredState *deferredState)
1193 QQmlData *ddata = QQmlData::get(object);
1194 Q_ASSERT(!ddata->deferredData.isEmpty());
1196 deferredState->reserve(ddata->deferredData.size());
1198 for (QQmlData::DeferredData *deferredData : std::as_const(ddata->deferredData)) {
1199 enginePriv->inProgressCreations++;
1201 ConstructionState state;
1202 state.setCompletePending(
true);
1204 auto creator = state.initCreator(
1205 deferredData->context->parent(),
1206 deferredData->compilationUnit,
1207 QQmlRefPointer<QQmlContextData>(),
1208 deferredData->inlineComponentName
1211 if (!creator->populateDeferredProperties(object, deferredData))
1212 state.appendCreatorErrors();
1213 deferredData->bindings.clear();
1215 deferredState->push_back(std::move(state));
1219void QQmlComponentPrivate::completeDeferred(QQmlEnginePrivate *enginePriv, QQmlComponentPrivate::DeferredState *deferredState)
1221 for (ConstructionState &state : *deferredState)
1222 complete(enginePriv, &state);
1225void QQmlComponentPrivate::complete(QQmlEnginePrivate *enginePriv, ConstructionState *state)
1227 if (state->isCompletePending()) {
1228 QQmlInstantiationInterrupt interrupt;
1229 state->creator()->finalize(interrupt);
1231 state->setCompletePending(
false);
1233 enginePriv->inProgressCreations--;
1235 if (0 == enginePriv->inProgressCreations) {
1236 while (enginePriv->erroredBindings) {
1237 enginePriv->warning(enginePriv->erroredBindings->removeError());
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260QQmlProperty QQmlComponentPrivate::removePropertyFromRequired(
1261 QObject *createdComponent,
const QString &name,
1262 RequiredProperties *requiredProperties, QQmlEngine *engine,
1263 bool *wasInRequiredProperties)
1265 Q_ASSERT(requiredProperties);
1266 QQmlProperty prop(createdComponent, name, engine);
1267 auto privProp = QQmlPropertyPrivate::get(prop);
1268 if (prop.isValid()) {
1270 const QQmlPropertyData *targetProp = &privProp->core;
1271 if (targetProp->isAlias()) {
1272 auto target = createdComponent;
1273 QQmlPropertyIndex originalIndex(targetProp->coreIndex());
1274 QQmlPropertyIndex propIndex;
1275 QQmlPropertyPrivate::findAliasTarget(target, originalIndex, &target, &propIndex);
1276 QQmlData *data = QQmlData::get(target);
1277 Q_ASSERT(data && data->propertyCache);
1278 targetProp = data->propertyCache->property(propIndex.coreIndex());
1282 QQmlData *data = QQmlData::get(createdComponent);
1283 Q_ASSERT(data && data->propertyCache);
1284 targetProp = data->propertyCache->property(targetProp->coreIndex());
1286 auto it = requiredProperties->constFind({createdComponent, targetProp});
1287 if (it != requiredProperties->cend()) {
1288 if (wasInRequiredProperties)
1289 *wasInRequiredProperties =
true;
1290 requiredProperties->erase(it);
1292 if (wasInRequiredProperties)
1293 *wasInRequiredProperties =
false;
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309void QQmlComponent::completeCreate()
1313 d->completeCreate();
1316void QQmlComponentPrivate::completeCreate()
1318 if (m_state.hasUnsetRequiredProperties()) {
1319 for (
const auto& unsetRequiredProperty: std::as_const(*m_state.requiredProperties())) {
1320 QQmlError error = unsetRequiredPropertyToQQmlError(unsetRequiredProperty);
1321 m_state.errors.push_back(QQmlComponentPrivate::AnnotatedQmlError { error,
true });
1325 const QQmlType type = loadedType();
1326 if (type.isValid()) {
1327 QObject *rv = m_state.target();
1328 if (QQmlParserStatus *parserStatus = parserStatusCast(type, rv))
1329 parserStatus->componentComplete();
1331 if (
const int finalizerCast = type.finalizerCast(); finalizerCast != -1) {
1332 auto *hook =
reinterpret_cast<QQmlFinalizerHook *>(
1333 reinterpret_cast<
char *>(rv) + finalizerCast);
1334 hook->componentFinalized();
1338
1339
1340
1341
1342 m_state.setCompletePending(
false);
1343 QQmlEnginePrivate::get(m_engine)->inProgressCreations--;
1344 }
else if (m_state.isCompletePending()) {
1346 QQmlEnginePrivate *ep = QQmlEnginePrivate::get(m_engine);
1347 complete(ep, &m_state);
1352QQmlComponentAttached::QQmlComponentAttached(QObject *parent)
1353: QObject(parent), m_prev(
nullptr), m_next(
nullptr)
1357QQmlComponentAttached::~QQmlComponentAttached()
1359 if (m_prev) *m_prev = m_next;
1360 if (m_next) m_next->m_prev = m_prev;
1366
1367
1368QQmlComponentAttached *QQmlComponent::qmlAttachedProperties(QObject *obj)
1370 QQmlComponentAttached *a =
new QQmlComponentAttached(obj);
1372 QQmlEngine *engine = qmlEngine(obj);
1376 QQmlEnginePrivate *p = QQmlEnginePrivate::get(engine);
1377 if (p->activeObjectCreator) {
1378 a->insertIntoList(p->activeObjectCreator->componentAttachment());
1380 QQmlData *d = QQmlData::get(obj);
1382 Q_ASSERT(d->context);
1383 d->context->addComponentAttached(a);
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406void QQmlComponent::loadFromModule(QAnyStringView uri, QAnyStringView typeName,
1407 QQmlComponent::CompilationMode mode)
1411 QQmlTypeLoader::Mode typeLoaderMode = QQmlTypeLoader::Synchronous;
1413 case QQmlComponent::PreferSynchronous:
1414 typeLoaderMode = QQmlTypeLoader::PreferSynchronous;
1416 case QQmlComponent::Asynchronous:
1417 typeLoaderMode = QQmlTypeLoader::Asynchronous;
1421 d->prepareLoadFromModule(uri, typeName, typeLoaderMode);
1422 if (d->m_loadHelper->isCompleteOrError())
1423 d->completeLoadFromModule(uri, typeName);
1425 d->m_loadHelper->registerCallback(d);
1428void QQmlComponentPrivate::prepareLoadFromModule(
1429 QAnyStringView uri, QAnyStringView typeName, QQmlTypeLoader::Mode mode)
1433 m_loadHelper->unregisterCallback(
this);
1436 m_loadHelper = QQml::makeRefPointer<LoadHelper>(QQmlTypeLoader::get(m_engine), uri, typeName, mode);
1439void QQmlComponentPrivate::completeLoadFromModule(QAnyStringView uri, QAnyStringView typeName)
1444 auto reportError = [&](QString msg) {
1446 error.setDescription(msg);
1447 m_state.errors.push_back(std::move(error));
1449 emit q->statusChanged(q->Error);
1451 auto emitComplete = [&]() {
1453 emit q->statusChanged(q->status());
1458 const QQmlType type = m_loadHelper->type();
1460 if (m_loadHelper->resolveTypeResult() == LoadHelper::ResolveTypeResult::NoSuchModule) {
1461 reportError(QLatin1String(R"(No module named "%1" found)").arg(uri.toString()));
1462 }
else if (!type.isValid()) {
1463 reportError(QLatin1String(R"(Module "%1" contains no type named "%2")")
1464 .arg(uri.toString(), typeName.toString()));
1465 }
else if (type.isCreatable()) {
1467 }
else if (type.isComposite()) {
1468 QQmlComponent::CompilationMode mode = QQmlComponent::PreferSynchronous;
1469 switch (m_loadHelper->mode()) {
1470 case QQmlTypeLoader::Asynchronous:
1471 mode = QQmlComponent::Asynchronous;
1473 case QQmlTypeLoader::PreferSynchronous:
1474 case QQmlTypeLoader::Synchronous:
1475 mode = QQmlComponent::PreferSynchronous;
1480 loadUrl(type.sourceUrl(), mode);
1481 }
else if (type.isInlineComponentType()) {
1482 auto baseUrl = type.sourceUrl();
1483 baseUrl.setFragment(QString());
1485 Q_ASSERT(m_progress == 0.0);
1489 QSignalBlocker blockSignals(q);
1491 loadUrl(baseUrl, QQmlComponent::PreferSynchronous);
1494 if (m_progress != 0.0)
1495 emit q->progressChanged(m_progress);
1501 QString elementName = type.elementName();
1502 if (m_compilationUnit->inlineComponentId(elementName) == -1) {
1503 QString realTypeName = typeName.toString();
1504 realTypeName.truncate(realTypeName.indexOf(u'.'));
1505 QString errorMessage = R"(Type "%1" from module "%2" contains no inline component named "%3".)"_L1.arg(
1506 realTypeName, uri.toString(), elementName);
1507 if (elementName == u"qml")
1508 errorMessage +=
" To load the type \"%1\", drop the \".qml\" extension."_L1.arg(realTypeName);
1509 reportError(std::move(errorMessage));
1511 m_inlineComponentName = std::make_unique<QString>(std::move(elementName));
1514 }
else if (type.isSingleton() || type.isCompositeSingleton()) {
1515 reportError(QLatin1String(R"(%1 is a singleton, and cannot be loaded)").arg(typeName.toString()));
1517 reportError(QLatin1String(
"Could not load %1, as the type is uncreatable").arg(typeName.toString()));
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1541void QQmlComponent::create(QQmlIncubator &incubator, QQmlContext *context, QQmlContext *forContext)
1546 context = d->m_engine->rootContext();
1548 QQmlRefPointer<QQmlContextData> contextData = QQmlContextData::get(context);
1549 QQmlRefPointer<QQmlContextData> forContextData =
1550 forContext ? QQmlContextData::get(forContext) : contextData;
1552 if (!contextData->isValid()) {
1553 qWarning(
"QQmlComponent: Cannot create a component in an invalid context");
1557 if (contextData->engine() != d->m_engine) {
1558 qWarning(
"QQmlComponent: Must create component in context from the same QQmlEngine");
1563 qWarning(
"QQmlComponent: Component is not ready");
1568 QExplicitlySharedDataPointer<QQmlIncubatorPrivate> p(incubator.d);
1570 if (d->loadedType().isValid()) {
1574 p->incubateCppBasedComponent(
this, context);
1578 QQmlEnginePrivate *enginePriv = QQmlEnginePrivate::get(d->m_engine);
1580 p->compilationUnit = d->m_compilationUnit;
1581 p->enginePriv = enginePriv;
1582 p->creator.reset(
new QQmlObjectCreator(
1583 contextData, d->m_compilationUnit, d->m_creationContext,
1584 d->m_inlineComponentName ? *d->m_inlineComponentName : QString(), p.data()));
1585 p->subComponentToCreate = d->m_start;
1587 enginePriv->incubate(incubator, forContextData);
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613void QQmlComponent::setInitialProperties(QObject *object,
const QVariantMap &properties)
1616 for (
auto it = properties.constBegin(); it != properties.constEnd(); ++it) {
1617 if (it.key().contains(u'.')) {
1618 auto segments = it.key().split(u'.');
1619 QString description = u"Setting initial properties failed: Cannot initialize nested "_s
1621 if (segments.size() >= 2) {
1622 QString s = u" To set %1.%2 as an initial property, create %1, set its "_s
1623 u"property %2, and pass %1 as an initial property."_s;
1624 description += s.arg(segments[0], segments[1]);
1627 error.setUrl(url());
1628 error.setDescription(description);
1629 qmlWarning(object, error);
1632 d->setInitialProperty(object, it.key(), it.value());
1637
1638
1639
1640
1641
1642
1643void QQmlComponentPrivate::incubateObject(
1644 QQmlIncubator *incubationTask,
1645 QQmlComponent *component,
1647 const QQmlRefPointer<QQmlContextData> &context,
1648 const QQmlRefPointer<QQmlContextData> &forContext)
1650 QQmlIncubatorPrivate *incubatorPriv = QQmlIncubatorPrivate::get(incubationTask);
1651 QQmlEnginePrivate *enginePriv = QQmlEnginePrivate::get(engine);
1652 QQmlComponentPrivate *componentPriv = QQmlComponentPrivate::get(component);
1654 incubatorPriv->compilationUnit = componentPriv->m_compilationUnit;
1655 incubatorPriv->enginePriv = enginePriv;
1656 incubatorPriv->creator.reset(
new QQmlObjectCreator(
1657 context, componentPriv->m_compilationUnit, componentPriv->m_creationContext,
1658 m_inlineComponentName ? *m_inlineComponentName : QString()));
1660 if (m_start == -1) {
1661 if (
const QString *icName = componentPriv->m_inlineComponentName.get()) {
1662 m_start = m_compilationUnit->inlineComponentId(*icName);
1663 Q_ASSERT(m_start > 0);
1666 incubatorPriv->subComponentToCreate = componentPriv->m_start;
1668 enginePriv->incubate(*incubationTask, forContext);
1679#define QmlIncubatorObjectMembers(class, Member)
1680 Member(class, HeapValue, HeapValue, valuemapOrObject)
1681 Member(class, HeapValue, HeapValue, statusChanged)
1682 Member(class, Pointer, QmlContext *, qmlContext)
1683 Member(class, NoMark, QQmlComponentIncubator *, incubator)
1684 Member(class, NoMark, QV4QPointer<QObject>, parent)
1687 DECLARE_MARKOBJECTS(QmlIncubatorObject)
1689 void init(QQmlIncubator::IncubationMode = QQmlIncubator::Asynchronous);
1690 inline void destroy();
1720 incubatorObject.set(inc->internalClass->engine, inc);
1724 QV4::Scope scope(incubatorObject.engine());
1725 QV4::Scoped<QV4::QmlIncubatorObject> i(scope, incubatorObject.as<QV4::QmlIncubatorObject>());
1726 i->statusChanged(s);
1730 QV4::Scope scope(incubatorObject.engine());
1731 QV4::Scoped<QV4::QmlIncubatorObject> i(scope, incubatorObject.as<QV4::QmlIncubatorObject>());
1732 auto d = QQmlIncubatorPrivate::get(
this);
1733 i->setInitialState(o, d->requiredProperties());
1743 me->setParent(parent);
1744 typedef QQmlPrivate::AutoParentFunction APF;
1745 QList<APF> functions = QQmlMetaType::parentFunctions();
1747 bool needParent =
false;
1748 for (
int ii = 0; ii < functions.size(); ++ii) {
1749 QQmlPrivate::AutoParentResult res = functions.at(ii)(me, parent);
1750 if (res == QQmlPrivate::Parented) {
1753 }
else if (res == QQmlPrivate::IncompatibleParent) {
1758 qmlWarning(me) <<
"Created graphical object was not placed in the graphics scene.";
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1805void QQmlComponentPrivate::setInitialProperties(
1806 QV4::ExecutionEngine *engine, QV4::QmlContext *qmlContext,
const QV4::Value &o,
1807 const QV4::Value &v, RequiredProperties *requiredProperties, QObject *createdComponent,
1808 const QQmlObjectCreator *creator)
1810 QV4::Scope scope(engine);
1811 QV4::ScopedObject object(scope);
1812 QV4::ScopedObject valueMap(scope, v);
1813 QV4::ObjectIterator it(scope, valueMap, QV4::ObjectIterator::EnumerableOnly);
1814 QV4::ScopedString name(scope);
1815 QV4::ScopedValue val(scope);
1816 if (engine->hasException)
1820 QV4::ScopedStackFrame frame(scope, qmlContext ? qmlContext : engine->scriptContext());
1823 name = it.nextPropertyNameAsString(val);
1827 const QStringList properties = name->toQString().split(QLatin1Char(
'.'));
1828 bool isTopLevelProperty = properties.size() == 1;
1829 for (
int i = 0; i < properties.size() - 1; ++i) {
1830 name = engine->newString(properties.at(i));
1831 object = object->get(name);
1832 if (engine->hasException || !object) {
1836 if (engine->hasException) {
1837 qmlWarning(createdComponent, engine->catchExceptionAsQmlError());
1842 error.setUrl(qmlContext ? qmlContext->qmlContext()->url() : QUrl());
1843 error.setDescription(QLatin1String(
"Cannot resolve property \"%1\".")
1844 .arg(properties.join(u'.')));
1845 qmlWarning(createdComponent, error);
1848 const QString lastProperty = properties.last();
1849 name = engine->newString(lastProperty);
1850 object->put(name, val);
1851 if (engine->hasException) {
1852 qmlWarning(createdComponent, engine->catchExceptionAsQmlError());
1854 }
else if (isTopLevelProperty && requiredProperties) {
1855 auto prop = removePropertyFromRequired(createdComponent, name->toQString(),
1856 requiredProperties, engine->qmlEngine());
1859 removePendingQPropertyBinding(object, lastProperty, creator);
1862 engine->hasException =
false;
1865QQmlError QQmlComponentPrivate::unsetRequiredPropertyToQQmlError(
const RequiredPropertyInfo &unsetRequiredProperty)
1868 QString description = QLatin1String(
"Required property %1 was not initialized").arg(unsetRequiredProperty.propertyName);
1869 switch (unsetRequiredProperty.aliasesToRequired.size()) {
1873 const auto info = unsetRequiredProperty.aliasesToRequired.first();
1874 description += QLatin1String(
"\nIt can be set via the alias property %1 from %2\n").arg(info.propertyName, info.fileUrl.toString());
1878 description += QLatin1String(
"\nIt can be set via one of the following alias properties:");
1879 for (
auto aliasInfo: unsetRequiredProperty.aliasesToRequired) {
1880 description += QLatin1String(
"\n- %1 (%2)").arg(aliasInfo.propertyName, aliasInfo.fileUrl.toString());
1882 description += QLatin1Char(
'\n');
1884 error.setDescription(description);
1885 error.setUrl(unsetRequiredProperty.fileUrl);
1886 error.setLine(qmlConvertSourceCoordinate<quint32,
int>(
1887 unsetRequiredProperty.location.line()));
1888 error.setColumn(qmlConvertSourceCoordinate<quint32,
int>(
1889 unsetRequiredProperty.location.column()));
1893#if QT_DEPRECATED_SINCE(6
, 3
)
1895
1896
1897void QQmlComponent::createObject(QQmlV4FunctionPtr args)
1900 Q_ASSERT(d->m_engine);
1903 qmlWarning(
this) <<
"Unsuitable arguments passed to createObject(). The first argument should "
1904 "be a QObject* or null, and the second argument should be a JavaScript "
1905 "object or a QVariantMap";
1907 QObject *parent =
nullptr;
1908 QV4::ExecutionEngine *v4 = args->v4engine();
1909 QV4::Scope scope(v4);
1910 QV4::ScopedValue valuemap(scope, QV4::Value::undefinedValue());
1912 if (args->length() >= 1) {
1913 QV4::Scoped<QV4::QObjectWrapper> qobjectWrapper(scope, (*args)[0]);
1915 parent = qobjectWrapper->object();
1918 if (args->length() >= 2) {
1919 QV4::ScopedValue v(scope, (*args)[1]);
1920 if (!v->as<QV4::Object>() || v->as<QV4::ArrayObject>()) {
1921 qmlWarning(
this) << tr(
"createObject: value is not an object");
1922 args->setReturnValue(QV4::Encode::null());
1928 QQmlContext *ctxt = creationContext();
1929 if (!ctxt) ctxt = d->m_engine->rootContext();
1931 QObject *rv = beginCreate(ctxt);
1934 args->setReturnValue(QV4::Encode::null());
1938 QQmlComponent_setQmlParent(rv, parent);
1940 QV4::ScopedValue object(scope, QV4::QObjectWrapper::wrap(v4, rv));
1941 Q_ASSERT(object->isObject());
1943 if (!valuemap->isUndefined()) {
1944 QV4::Scoped<QV4::QmlContext> qmlContext(scope, v4->qmlContext());
1945 QQmlComponentPrivate::setInitialProperties(
1946 v4, qmlContext, object, valuemap, d->m_state.requiredProperties(), rv,
1947 d->m_state.creator());
1949 if (d->m_state.hasUnsetRequiredProperties()) {
1950 QList<QQmlError> errors;
1951 for (
const auto &requiredProperty: std::as_const(*d->m_state.requiredProperties())) {
1952 errors.push_back(QQmlComponentPrivate::unsetRequiredPropertyToQQmlError(requiredProperty));
1954 qmlWarning(rv, errors);
1955 args->setReturnValue(QV4::Encode::null());
1960 d->completeCreate();
1962 Q_ASSERT(QQmlData::get(rv));
1963 QQmlData::get(rv)->explicitIndestructibleSet =
false;
1964 QQmlData::get(rv)->indestructible =
false;
1966 args->setReturnValue(object->asReturnedValue());
1971
1972
1973QObject *QQmlComponent::createObject(QObject *parent,
const QVariantMap &properties)
1976 Q_ASSERT(d->m_engine);
1977 QObject *rv = d->createWithProperties(parent, properties, creationContext(),
1978 QQmlComponentPrivate::CreateWarnAboutRequiredProperties,
1981 QQmlData *qmlData = QQmlData::get(rv);
1983 qmlData->explicitIndestructibleSet =
false;
1984 qmlData->indestructible =
false;
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2045
2046
2047void QQmlComponent::incubateObject(QQmlV4FunctionPtr args)
2050 Q_ASSERT(d->m_engine);
2053 QV4::ExecutionEngine *v4 = args->v4engine();
2054 QV4::Scope scope(v4);
2056 QObject *parent =
nullptr;
2057 QV4::ScopedValue valuemap(scope, QV4::Value::undefinedValue());
2058 QQmlIncubator::IncubationMode mode = QQmlIncubator::Asynchronous;
2060 if (args->length() >= 1) {
2061 QV4::Scoped<QV4::QObjectWrapper> qobjectWrapper(scope, (*args)[0]);
2063 parent = qobjectWrapper->object();
2066 if (args->length() >= 2) {
2067 QV4::ScopedValue v(scope, (*args)[1]);
2069 }
else if (!v->as<QV4::Object>() || v->as<QV4::ArrayObject>()) {
2070 qmlWarning(
this) << tr(
"createObject: value is not an object");
2071 args->setReturnValue(QV4::Encode::null());
2078 if (args->length() >= 3) {
2079 QV4::ScopedValue val(scope, (*args)[2]);
2080 quint32 v = val->toUInt32();
2082 mode = QQmlIncubator::Asynchronous;
2084 mode = QQmlIncubator::AsynchronousIfNested;
2087 QQmlComponentExtension *e = componentExtension(args->v4engine());
2089 QV4::Scoped<QV4::QmlIncubatorObject> r(scope, v4->memoryManager->allocate<QV4::QmlIncubatorObject>(mode));
2090 QV4::ScopedObject p(scope, e->incubationProto.value());
2091 r->setPrototypeOf(p);
2093 if (!valuemap->isUndefined())
2094 r->d()->valuemapOrObject.set(scope.engine, valuemap);
2095 r->d()->qmlContext.set(scope.engine, v4->qmlContext());
2096 r->d()->parent = parent;
2098 QQmlIncubator *incubator = r->d()->incubator;
2099 create(*incubator, creationContext());
2101 if (incubator->status() == QQmlIncubator::Null) {
2102 args->setReturnValue(QV4::Encode::null());
2104 args->setReturnValue(r.asReturnedValue());
2109void QQmlComponentPrivate::initializeObjectWithInitialProperties(QV4::QmlContext *qmlContext,
const QV4::Value &valuemap, QObject *toCreate, RequiredProperties *requiredProperties)
2111 QV4::ExecutionEngine *v4engine = m_engine->handle();
2112 QV4::Scope scope(v4engine);
2114 QV4::ScopedValue object(scope, QV4::QObjectWrapper::wrap(v4engine, toCreate));
2115 Q_ASSERT(object->as<QV4::Object>());
2117 if (!valuemap.isUndefined()) {
2118 setInitialProperties(
2119 v4engine, qmlContext, object, valuemap, requiredProperties, toCreate, m_state.creator());
2123QQmlComponentExtension::QQmlComponentExtension(QV4::ExecutionEngine *v4)
2125 QV4::Scope scope(v4);
2126 QV4::ScopedObject proto(scope, v4->newObject());
2127 proto->defineAccessorProperty(QStringLiteral(
"onStatusChanged"),
2128 QV4::QmlIncubatorObject::method_get_statusChanged, QV4::QmlIncubatorObject::method_set_statusChanged);
2129 proto->defineAccessorProperty(QStringLiteral(
"status"), QV4::QmlIncubatorObject::method_get_status,
nullptr);
2130 proto->defineAccessorProperty(QStringLiteral(
"object"), QV4::QmlIncubatorObject::method_get_object,
nullptr);
2131 proto->defineDefaultProperty(QStringLiteral(
"forceCompletion"), QV4::QmlIncubatorObject::method_forceCompletion);
2133 incubationProto.set(v4, proto);
2136QV4::ReturnedValue
QV4::
QmlIncubatorObject::method_get_object(
const FunctionObject *b,
const Value *thisObject,
const Value *,
int)
2138 QV4::Scope scope(b);
2139 QV4::Scoped<QmlIncubatorObject> o(scope, thisObject->as<QmlIncubatorObject>());
2143 return QV4::QObjectWrapper::wrap(scope.engine, o->d()->incubator->object());
2146QV4::ReturnedValue
QV4::
QmlIncubatorObject::method_forceCompletion(
const FunctionObject *b,
const Value *thisObject,
const Value *,
int)
2148 QV4::Scope scope(b);
2149 QV4::Scoped<QmlIncubatorObject> o(scope, thisObject->as<QmlIncubatorObject>());
2153 o->d()->incubator->forceCompletion();
2158QV4::ReturnedValue
QV4::
QmlIncubatorObject::method_get_status(
const FunctionObject *b,
const Value *thisObject,
const Value *,
int)
2160 QV4::Scope scope(b);
2161 QV4::Scoped<QmlIncubatorObject> o(scope, thisObject->as<QmlIncubatorObject>());
2165 return QV4::Encode(o->d()->incubator->status());
2168QV4::ReturnedValue
QV4::
QmlIncubatorObject::method_get_statusChanged(
const FunctionObject *b,
const Value *thisObject,
const Value *,
int)
2170 QV4::Scope scope(b);
2171 QV4::Scoped<QmlIncubatorObject> o(scope, thisObject->as<QmlIncubatorObject>());
2175 return QV4::Encode(o->d()->statusChanged);
2178QV4::ReturnedValue
QV4::
QmlIncubatorObject::method_set_statusChanged(
const FunctionObject *b,
const Value *thisObject,
const Value *argv,
int argc)
2180 QV4::Scope scope(b);
2181 QV4::Scoped<QmlIncubatorObject> o(scope, thisObject->as<QmlIncubatorObject>());
2185 o->d()->statusChanged.set(scope.engine, argv[0]);
2190QQmlComponentExtension::~QQmlComponentExtension()
2194void QV4::Heap::QmlIncubatorObject::init(QQmlIncubator::IncubationMode m)
2197 valuemapOrObject.set(internalClass->engine, QV4::Value::undefinedValue());
2198 statusChanged.set(internalClass->engine, QV4::Value::undefinedValue());
2200 qmlContext.set(internalClass->engine,
nullptr);
2201 incubator =
new QQmlComponentIncubator(
this, m);
2204void QV4::Heap::QmlIncubatorObject::destroy() {
2212 QQmlComponent_setQmlParent(o, d()->parent);
2214 if (!d()->valuemapOrObject.isUndefined()) {
2215 QV4::ExecutionEngine *v4 = engine();
2216 QV4::Scope scope(v4);
2217 QV4::ScopedObject obj(scope, QV4::QObjectWrapper::wrap(v4, o));
2218 QV4::Scoped<QV4::QmlContext> qmlCtxt(scope, d()->qmlContext);
2219 QQmlComponentPrivate::setInitialProperties(
2220 v4, qmlCtxt, obj, d()->valuemapOrObject, requiredProperties, o,
2221 QQmlIncubatorPrivate::get(d()->incubator)->creator.data());
2227 QV4::Scope scope(engine());
2229 QObject *object = d()->incubator->object();
2231 if (s == QQmlIncubator::Ready) {
2234 d()->valuemapOrObject.set(scope.engine, QV4::QObjectWrapper::wrap(scope.engine, object));
2236 QQmlData *ddata = QQmlData::get(object);
2238 ddata->explicitIndestructibleSet =
false;
2239 ddata->indestructible =
false;
2242 QV4::ScopedFunctionObject f(scope, d()->statusChanged);
2244 QV4::JSCallArguments jsCallData(scope, 1);
2245 *jsCallData.thisObject =
this;
2246 jsCallData.args[0] = QV4::Value::fromUInt32(s);
2247 f->call(jsCallData);
2248 if (scope.hasException()) {
2249 QQmlError error = scope.engine->catchExceptionAsQmlError();
2250 QQmlEnginePrivate::warning(QQmlEnginePrivate::get(scope.engine->qmlEngine()), error);
2254 if (s != QQmlIncubator::Loading)
2255 d()->incubator->incubatorObject.clear();
2258#undef INITIALPROPERTIES_SOURCE
2262#include "moc_qqmlcomponent.cpp"
2263#include "moc_qqmlcomponentattached_p.cpp"
void setInitialState(QObject *o) override
Called after the object is first created, but before complex property bindings are evaluated and,...
void statusChanged(Status s) override
Called when the status of the incubator changes.
QQmlComponentIncubator(QV4::Heap::QmlIncubatorObject *inc, IncubationMode mode)
QV4::PersistentValue incubatorObject
The QQmlError class encapsulates a QML error.
Status
Specifies the status of the QQmlIncubator.
DECLARE_HEAP_OBJECT(QmlContext, ExecutionContext)
Q_STATIC_LOGGING_CATEGORY(lcAccessibilityCore, "qt.accessibility.core")
static void removePendingQPropertyBinding(QV4::Value *object, const QString &propertyName, const QQmlObjectCreator *creator)
static void QQmlComponent_setQmlParent(QObject *me, QObject *parent)
DEFINE_OBJECT_VTABLE(QV4::QmlIncubatorObject)
V4_DEFINE_EXTENSION(QQmlComponentExtension, componentExtension)
static QQmlParserStatus * parserStatusCast(const QQmlType &type, QObject *rv)
static ReturnedValue method_set_statusChanged(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_get_status(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_get_object(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
void statusChanged(QQmlIncubator::Status)
void setInitialState(QObject *, RequiredProperties *requiredProperties)
static ReturnedValue method_forceCompletion(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)