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 const QStringList properties = name.split(u'.');
389 if (properties.size() > 1) {
390 QV4::Scope scope(m_engine->handle());
391 QV4::ScopedObject object(scope, QV4::QObjectWrapper::wrap(scope.engine, base));
392 QV4::ScopedString segment(scope);
394 for (
int i = 0; i < properties.size() - 1; ++i) {
395 segment = scope.engine->newString(properties.at(i));
396 object = object->get(segment);
397 if (scope.engine->hasException)
400 const QString lastProperty = properties.last();
401 segment = scope.engine->newString(lastProperty);
402 QV4::ScopedValue v(scope, scope.engine->metaTypeToJS(value.metaType(), value.constData()));
403 object->put(segment, v);
404 if (scope.engine->hasException) {
405 qmlWarning(base, scope.engine->catchExceptionAsQmlError());
406 scope.engine->hasException =
false;
410 removePendingQPropertyBinding(object, lastProperty, m_state.creator());
415 if (m_state.hasUnsetRequiredProperties())
416 prop = QQmlComponentPrivate::removePropertyFromRequired(
417 base, name, m_state.requiredProperties(), m_engine);
419 prop = QQmlProperty(base, name, m_engine);
420 QQmlPropertyPrivate *privProp = QQmlPropertyPrivate::get(prop);
421 const bool isValid = prop.isValid();
422 if (isValid && privProp->writeValueProperty(value, {})) {
423 if (prop.isBindable()) {
424 if (QQmlObjectCreator *creator = m_state.creator())
425 creator->removePendingBinding(prop.object(), prop.index());
431 error.setDescription(QStringLiteral(
"Could not set initial property %1").arg(name));
433 error.setDescription(QStringLiteral(
"Setting initial properties failed: "
434 "%2 does not have a property called %1")
435 .arg(name, QQmlMetaType::prettyTypeName(base)));
437 qmlWarning(base, error);
446
447
448QQmlComponent::QQmlComponent(QObject *parent)
449 : QObject(*(
new QQmlComponentPrivate), parent)
454
455
456QQmlComponent::~QQmlComponent()
460 if (d->m_state.isCompletePending()) {
461 qWarning(
"QQmlComponent: Component destroyed while completion pending");
464 qWarning() <<
"This may have been caused by one of the following errors:";
465 for (
const QQmlComponentPrivate::AnnotatedQmlError &e : std::as_const(d->m_state.errors))
466 qWarning().nospace().noquote() << QLatin1String(
" ") << e.error;
470 if (d->m_state.hasCreator())
475 d->m_typeData->unregisterCallback(d);
476 if (d->m_engine && !d->m_typeData->isCompleteOrError()) {
479 QQmlTypeLoader::get(d->m_engine)->drop(QQmlDataBlob::Ptr(d->m_typeData.data()));
481 d->m_typeData.reset();
486
487
488
489
490
491
492
493
494
495
496
499
500
501
502QQmlComponent::Status QQmlComponent::status()
const
504 Q_D(
const QQmlComponent);
508 else if (!d->m_state.errors.isEmpty())
510 else if (d->m_engine && (d->m_compilationUnit || d->loadedType().isValid()))
512 else if (d->m_loadHelper)
519
520
521bool QQmlComponent::isNull()
const
523 return status() == Null;
527
528
529bool QQmlComponent::isReady()
const
531 return status() == Ready;
535
536
537bool QQmlComponent::isError()
const
539 return status() == Error;
543
544
545bool QQmlComponent::isLoading()
const
547 return status() == Loading;
551
552
553
554
555
556bool QQmlComponent::isBound()
const
558 Q_D(
const QQmlComponent);
563
564
565
566
569
570
571
572
573qreal QQmlComponent::progress()
const
575 Q_D(
const QQmlComponent);
576 return d->m_progress;
580
581
582
583
584
587
588
589
590
591
594
595
596
597QQmlComponent::QQmlComponent(QQmlEngine *engine, QObject *parent)
598 : QObject(*(
new QQmlComponentPrivate), parent)
601 d->m_engine = engine;
602 QObject::connect(engine, &QObject::destroyed,
this, [d]() {
604 d->m_engine =
nullptr;
609
610
611
612
613
614
615
616QQmlComponent::QQmlComponent(QQmlEngine *engine,
const QUrl &url, QObject *parent)
617 : QQmlComponent(engine, url, QQmlComponent::PreferSynchronous, parent)
622
623
624
625
626
627
628
629
630QQmlComponent::QQmlComponent(QQmlEngine *engine,
const QUrl &url, CompilationMode mode,
632 : QQmlComponent(engine, parent)
635 d->loadUrl(url, mode);
639
640
641
642
643
644
645
646
647QQmlComponent::QQmlComponent(QQmlEngine *engine, QAnyStringView uri, QAnyStringView typeName, QObject *parent)
648 : QQmlComponent(engine, uri, typeName, QQmlComponent::PreferSynchronous, parent)
654
655
656
657
658
659
660
661
662QQmlComponent::QQmlComponent(QQmlEngine *engine, QAnyStringView uri, QAnyStringView typeName, CompilationMode mode, QObject *parent)
663 : QQmlComponent(engine, parent)
665 loadFromModule(uri, typeName, mode);
669
670
671
672
673
674QQmlComponent::QQmlComponent(QQmlEngine *engine,
const QString &fileName,
676 : QQmlComponent(engine, fileName, QQmlComponent::PreferSynchronous, parent)
681
682
683
684
685
686
687QQmlComponent::QQmlComponent(QQmlEngine *engine,
const QString &fileName,
688 CompilationMode mode, QObject *parent)
689 : QQmlComponent(engine, parent)
692 if (fileName.startsWith(u':'))
693 d->loadUrl(QUrl(QLatin1String(
"qrc") + fileName), mode);
694 else if (QDir::isAbsolutePath(fileName))
695 d->loadUrl(QUrl::fromLocalFile(fileName), mode);
697 d->loadUrl(QUrl(fileName), mode);
701
702
703QQmlComponent::QQmlComponent(QQmlEngine *engine, QV4::ExecutableCompilationUnit *compilationUnit,
704 int start, QObject *parent)
705 : QQmlComponent(engine, parent)
708 d->m_compilationUnit.reset(compilationUnit);
710 d->m_url = compilationUnit->finalUrl();
715
716
717
718
719
720
721
722void QQmlComponent::setData(
const QByteArray &data,
const QUrl &url)
728 qWarning(
"QQmlComponent: Must provide an engine before calling setData");
736 QQmlRefPointer<QQmlTypeData> typeData = QQmlTypeLoader::get(d->m_engine)->getType(data, url);
738 if (typeData->isCompleteOrError()) {
739 d->fromTypeData(typeData);
741 d->m_typeData = typeData;
742 d->m_typeData->registerCallback(d);
746 emit statusChanged(status());
750
751
752
753QQmlContext *QQmlComponent::creationContext()
const
755 Q_D(
const QQmlComponent);
756 if (!d->m_creationContext.isNull())
757 return d->m_creationContext->asQQmlContext();
759 return qmlContext(
this);
763
764
765
766
767QQmlEngine *QQmlComponent::engine()
const
769 Q_D(
const QQmlComponent);
774
775
776
777
778void QQmlComponent::loadUrl(
const QUrl &url)
785
786
787
788
789
790void QQmlComponent::loadUrl(
const QUrl &url, QQmlComponent::CompilationMode mode)
793 d->loadUrl(url, mode);
796void QQmlComponentPrivate::loadUrl(
const QUrl &newUrl, QQmlComponent::CompilationMode mode)
801 if (newUrl.isRelative()) {
803 m_url = m_engine->baseUrl().resolved(QUrl(newUrl.toString()));
804 }
else if (m_engine->baseUrl().isLocalFile() && newUrl.isLocalFile() && !QDir::isAbsolutePath(newUrl.toLocalFile())) {
808 QUrl fixedUrl(newUrl);
809 fixedUrl.setScheme(QString());
812 m_url = m_engine->baseUrl().resolved(fixedUrl);
817 if (m_url.scheme() ==
"qrc"_L1 && !m_url.path().startsWith(
"/"_L1)) {
818 qWarning().nospace().noquote()
819 <<
"QQmlComponent: attempted to load via a relative URL '" << m_url.toString()
820 <<
"' in resource file system. This is not fully supported and may not work";
823 if (newUrl.isEmpty()) {
825 error.setDescription(QQmlComponent::tr(
"Invalid empty URL"));
826 m_state.errors.emplaceBack(error);
832 QQmlTypeLoader::Mode loaderMode = (mode == QQmlComponent::Asynchronous)
833 ? QQmlTypeLoader::Asynchronous
834 : QQmlTypeLoader::PreferSynchronous;
835 QQmlRefPointer<QQmlTypeData> data = QQmlTypeLoader::get(m_engine)->getType(m_url, loaderMode);
837 if (data->isCompleteOrError()) {
842 m_typeData->registerCallback(
this);
843 setProgress(data->progress());
846 emit q->statusChanged(q->status());
850
851
852
853QList<QQmlError> QQmlComponent::errors()
const
855 Q_D(
const QQmlComponent);
856 QList<QQmlError> errors;
857 errors.reserve(d->m_state.errors.size());
858 for (
const QQmlComponentPrivate::AnnotatedQmlError &annotated : d->m_state.errors)
859 errors.emplaceBack(annotated.error);
864
865
866
867
868
869
870
871
872
875
876
877
878QString QQmlComponent::errorString()
const
880 Q_D(
const QQmlComponent);
884 for (
const QQmlComponentPrivate::AnnotatedQmlError &annotated : d->m_state.errors) {
885 const QQmlError &e = annotated.error;
886 ret += e.url().toString() + QLatin1Char(
':') +
887 QString::number(e.line()) + QLatin1Char(
' ') +
888 e.description() + QLatin1Char(
'\n');
894
895
896
899
900
901
902
903QUrl QQmlComponent::url()
const
905 Q_D(
const QQmlComponent);
910
911
912QQmlComponent::QQmlComponent(QQmlComponentPrivate &dd, QObject *parent)
913 : QObject(dd, parent)
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933QObject *QQmlComponent::create(QQmlContext *context)
936 return d->createWithProperties(
nullptr, QVariantMap {}, context);
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959QObject *QQmlComponent::createWithInitialProperties(
const QVariantMap& initialProperties, QQmlContext *context)
962 return d->createWithProperties(
nullptr, initialProperties, context);
968
969QObject *QQmlComponentPrivate::createWithProperties(QObject *parent,
const QVariantMap &properties,
970 QQmlContext *context, CreateBehavior behavior,
975 QObject *rv = doBeginCreate(q, context);
977 if (m_state.isCompletePending()) {
981 QQmlEnginePrivate *ep = QQmlEnginePrivate::get(m_engine);
982 complete(ep, &m_state);
988 QQmlComponent_setQmlParent(rv, parent);
991 for (
auto it = properties.cbegin(), end = properties.cend(); it != end; ++it)
992 setInitialProperty(rv, it.key(), it.value());
994 q->setInitialProperties(rv, properties);
998 if (m_state.hasUnsetRequiredProperties()) {
999 if (behavior == CreateWarnAboutRequiredProperties) {
1000 for (
const auto &unsetRequiredProperty : std::as_const(*m_state.requiredProperties())) {
1001 const QQmlError error = unsetRequiredPropertyToQQmlError(unsetRequiredProperty);
1002 qmlWarning(rv, error);
1012
1013
1014
1015
1016
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
1048QObject *QQmlComponent::beginCreate(QQmlContext *context)
1052 return d->beginCreate(QQmlContextData::get(context));
1057 const int parserStatusCast = type.parserStatusCast();
1058 return parserStatusCast == -1
1060 :
reinterpret_cast<QQmlParserStatus *>(
reinterpret_cast<
char *>(rv) + parserStatusCast);
1063QObject *QQmlComponentPrivate::beginCreate(QQmlRefPointer<QQmlContextData> context)
1066 auto cleanup = qScopeGuard([
this] {
1067 if (!m_state.errors.isEmpty() && lcQmlComponentGeneral().isDebugEnabled()) {
1068 for (
const auto &e : std::as_const(m_state.errors)) {
1069 qCDebug(lcQmlComponentGeneral) <<
"QQmlComponent: " << e.error.toString();
1074 qWarning(
"QQmlComponent: Cannot create a component in a null context");
1078 if (!context->isValid()) {
1079 qWarning(
"QQmlComponent: Cannot create a component in an invalid context");
1083 if (context->engine() != m_engine) {
1084 qWarning(
"QQmlComponent: Must create component in context from the same QQmlEngine");
1088 if (m_state.isCompletePending()) {
1089 qWarning(
"QQmlComponent: Cannot create new component instance before completing the previous");
1095 m_state.errors.removeIf([](
const auto &e) {
return e.isTransient; });
1096 m_state.clearRequiredProperties();
1098 if (!q->isReady()) {
1099 qWarning(
"QQmlComponent: Component is not ready");
1104 static const int maxCreationDepth = 10;
1105 if (creationDepth >= maxCreationDepth) {
1106 qWarning(
"QQmlComponent: Component creation is recursing - aborting");
1110 QQmlEnginePrivate *enginePriv = QQmlEnginePrivate::get(m_engine);
1112 enginePriv->inProgressCreations++;
1113 m_state.errors.clear();
1114 m_state.setCompletePending(
true);
1116 QObject *rv =
nullptr;
1118 const QQmlType type = loadedType();
1119 if (!type.isValid()) {
1120 enginePriv->referenceScarceResources();
1121 const QString *icName = m_inlineComponentName.get();
1122 m_state.initCreator(
1123 context, m_compilationUnit, m_creationContext, icName ? *icName : QString());
1125 QQmlObjectCreator::CreationFlags flags;
1127 flags = QQmlObjectCreator::InlineComponent;
1129 m_start = m_compilationUnit->inlineComponentId(*icName);
1130 Q_ASSERT(m_start > 0);
1132 flags = QQmlObjectCreator::NormalObject;
1135 rv = m_state.creator()->create(m_start,
nullptr,
nullptr, flags);
1137 m_state.appendCreatorErrors();
1138 enginePriv->dereferenceScarceResources();
1141 rv = type.createWithQQmlData();
1142 QQmlPropertyCache::ConstPtr propertyCache = QQmlData::ensurePropertyCache(rv);
1143 if (QQmlParserStatus *parserStatus = parserStatusCast(type, rv)) {
1144 parserStatus->classBegin();
1145 m_state.ensureRequiredPropertyStorage(rv);
1146 }
else if (type.finalizerCast() != -1) {
1147 m_state.ensureRequiredPropertyStorage(rv);
1150 if (propertyCache) {
1151 for (
int i = 0, propertyCount = propertyCache->propertyCount(); i < propertyCount; ++i) {
1152 if (
const QQmlPropertyData *propertyData = propertyCache->property(i); propertyData->isRequired()) {
1153 m_state.ensureRequiredPropertyStorage(rv);
1154 RequiredPropertyInfo info;
1155 info.propertyName = propertyData->name(rv);
1156 m_state.addPendingRequiredProperty(rv, propertyData, info);
1167 QQmlData *ddata = QQmlData::get(rv);
1171 ddata->indestructible =
true;
1172 ddata->explicitIndestructibleSet =
true;
1173 ddata->rootObjectInCreation =
false;
1176 if (!ddata->outerContext)
1177 ddata->outerContext = context.data();
1178 if (!ddata->context)
1179 ddata->context = context.data();
1185void QQmlComponentPrivate::beginDeferred(QQmlEnginePrivate *enginePriv,
1186 QObject *object, DeferredState *deferredState)
1188 QQmlData *ddata = QQmlData::get(object);
1189 Q_ASSERT(!ddata->deferredData.isEmpty());
1191 deferredState->reserve(ddata->deferredData.size());
1193 for (QQmlData::DeferredData *deferredData : std::as_const(ddata->deferredData)) {
1194 enginePriv->inProgressCreations++;
1196 ConstructionState state;
1197 state.setCompletePending(
true);
1199 auto creator = state.initCreator(
1200 deferredData->context->parent(),
1201 deferredData->compilationUnit,
1202 QQmlRefPointer<QQmlContextData>(),
1203 deferredData->inlineComponentName
1206 if (!creator->populateDeferredProperties(object, deferredData))
1207 state.appendCreatorErrors();
1208 deferredData->bindings.clear();
1210 deferredState->push_back(std::move(state));
1214void QQmlComponentPrivate::completeDeferred(QQmlEnginePrivate *enginePriv, QQmlComponentPrivate::DeferredState *deferredState)
1216 for (ConstructionState &state : *deferredState)
1217 complete(enginePriv, &state);
1220void QQmlComponentPrivate::complete(QQmlEnginePrivate *enginePriv, ConstructionState *state)
1222 if (state->isCompletePending()) {
1223 QQmlInstantiationInterrupt interrupt;
1224 state->creator()->finalize(interrupt);
1226 state->setCompletePending(
false);
1228 enginePriv->inProgressCreations--;
1230 if (0 == enginePriv->inProgressCreations) {
1231 while (enginePriv->erroredBindings) {
1232 enginePriv->warning(enginePriv->erroredBindings->removeError());
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255QQmlProperty QQmlComponentPrivate::removePropertyFromRequired(
1256 QObject *createdComponent,
const QString &name,
1257 RequiredProperties *requiredProperties, QQmlEngine *engine,
1258 bool *wasInRequiredProperties)
1260 Q_ASSERT(requiredProperties);
1261 QQmlProperty prop(createdComponent, name, engine);
1262 auto privProp = QQmlPropertyPrivate::get(prop);
1263 if (prop.isValid()) {
1265 const QQmlPropertyData *targetProp = &privProp->core;
1266 if (targetProp->isAlias()) {
1267 auto target = createdComponent;
1268 QQmlPropertyIndex originalIndex(targetProp->coreIndex());
1269 QQmlPropertyIndex propIndex;
1270 QQmlPropertyPrivate::findAliasTarget(target, originalIndex, &target, &propIndex);
1271 QQmlData *data = QQmlData::get(target);
1272 Q_ASSERT(data && data->propertyCache);
1273 targetProp = data->propertyCache->property(propIndex.coreIndex());
1277 QQmlData *data = QQmlData::get(createdComponent);
1278 Q_ASSERT(data && data->propertyCache);
1279 targetProp = data->propertyCache->property(targetProp->coreIndex());
1281 auto it = requiredProperties->constFind({createdComponent, targetProp});
1282 if (it != requiredProperties->cend()) {
1283 if (wasInRequiredProperties)
1284 *wasInRequiredProperties =
true;
1285 requiredProperties->erase(it);
1287 if (wasInRequiredProperties)
1288 *wasInRequiredProperties =
false;
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304void QQmlComponent::completeCreate()
1308 d->completeCreate();
1311void QQmlComponentPrivate::completeCreate()
1313 if (m_state.hasUnsetRequiredProperties()) {
1314 for (
const auto& unsetRequiredProperty: std::as_const(*m_state.requiredProperties())) {
1315 QQmlError error = unsetRequiredPropertyToQQmlError(unsetRequiredProperty);
1316 m_state.errors.push_back(QQmlComponentPrivate::AnnotatedQmlError { error,
true });
1320 const QQmlType type = loadedType();
1321 if (type.isValid()) {
1322 QObject *rv = m_state.target();
1323 if (QQmlParserStatus *parserStatus = parserStatusCast(type, rv))
1324 parserStatus->componentComplete();
1326 if (
const int finalizerCast = type.finalizerCast(); finalizerCast != -1) {
1327 auto *hook =
reinterpret_cast<QQmlFinalizerHook *>(
1328 reinterpret_cast<
char *>(rv) + finalizerCast);
1329 hook->componentFinalized();
1333
1334
1335
1336
1337 m_state.setCompletePending(
false);
1338 QQmlEnginePrivate::get(m_engine)->inProgressCreations--;
1339 }
else if (m_state.isCompletePending()) {
1341 QQmlEnginePrivate *ep = QQmlEnginePrivate::get(m_engine);
1342 complete(ep, &m_state);
1347QQmlComponentAttached::QQmlComponentAttached(QObject *parent)
1348: QObject(parent), m_prev(
nullptr), m_next(
nullptr)
1352QQmlComponentAttached::~QQmlComponentAttached()
1354 if (m_prev) *m_prev = m_next;
1355 if (m_next) m_next->m_prev = m_prev;
1361
1362
1363QQmlComponentAttached *QQmlComponent::qmlAttachedProperties(QObject *obj)
1365 QQmlComponentAttached *a =
new QQmlComponentAttached(obj);
1367 QQmlEngine *engine = qmlEngine(obj);
1371 QQmlEnginePrivate *p = QQmlEnginePrivate::get(engine);
1372 if (p->activeObjectCreator) {
1373 a->insertIntoList(p->activeObjectCreator->componentAttachment());
1375 QQmlData *d = QQmlData::get(obj);
1377 Q_ASSERT(d->context);
1378 d->context->addComponentAttached(a);
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401void QQmlComponent::loadFromModule(QAnyStringView uri, QAnyStringView typeName,
1402 QQmlComponent::CompilationMode mode)
1406 QQmlTypeLoader::Mode typeLoaderMode = QQmlTypeLoader::Synchronous;
1408 case QQmlComponent::PreferSynchronous:
1409 typeLoaderMode = QQmlTypeLoader::PreferSynchronous;
1411 case QQmlComponent::Asynchronous:
1412 typeLoaderMode = QQmlTypeLoader::Asynchronous;
1416 d->prepareLoadFromModule(uri, typeName, typeLoaderMode);
1417 if (d->m_loadHelper->isCompleteOrError())
1418 d->completeLoadFromModule(uri, typeName);
1420 d->m_loadHelper->registerCallback(d);
1423void QQmlComponentPrivate::prepareLoadFromModule(
1424 QAnyStringView uri, QAnyStringView typeName, QQmlTypeLoader::Mode mode)
1428 m_loadHelper->unregisterCallback(
this);
1431 m_loadHelper = QQml::makeRefPointer<LoadHelper>(QQmlTypeLoader::get(m_engine), uri, typeName, mode);
1434void QQmlComponentPrivate::completeLoadFromModule(QAnyStringView uri, QAnyStringView typeName)
1439 auto reportError = [&](QString msg) {
1441 error.setDescription(msg);
1442 m_state.errors.push_back(std::move(error));
1444 emit q->statusChanged(q->Error);
1446 auto emitComplete = [&]() {
1448 emit q->statusChanged(q->status());
1453 const QQmlType type = m_loadHelper->type();
1455 if (m_loadHelper->resolveTypeResult() == LoadHelper::ResolveTypeResult::NoSuchModule) {
1456 reportError(QLatin1String(R"(No module named "%1" found)").arg(uri.toString()));
1457 }
else if (!type.isValid()) {
1458 reportError(QLatin1String(R"(Module "%1" contains no type named "%2")")
1459 .arg(uri.toString(), typeName.toString()));
1460 }
else if (type.isCreatable()) {
1462 }
else if (type.isComposite()) {
1463 QQmlComponent::CompilationMode mode = QQmlComponent::PreferSynchronous;
1464 switch (m_loadHelper->mode()) {
1465 case QQmlTypeLoader::Asynchronous:
1466 mode = QQmlComponent::Asynchronous;
1468 case QQmlTypeLoader::PreferSynchronous:
1469 case QQmlTypeLoader::Synchronous:
1470 mode = QQmlComponent::PreferSynchronous;
1475 loadUrl(type.sourceUrl(), mode);
1476 }
else if (type.isInlineComponentType()) {
1477 auto baseUrl = type.sourceUrl();
1478 baseUrl.setFragment(QString());
1480 Q_ASSERT(m_progress == 0.0);
1484 QSignalBlocker blockSignals(q);
1486 loadUrl(baseUrl, QQmlComponent::PreferSynchronous);
1489 if (m_progress != 0.0)
1490 emit q->progressChanged(m_progress);
1496 QString elementName = type.elementName();
1497 if (m_compilationUnit->inlineComponentId(elementName) == -1) {
1498 QString realTypeName = typeName.toString();
1499 realTypeName.truncate(realTypeName.indexOf(u'.'));
1500 QString errorMessage = R"(Type "%1" from module "%2" contains no inline component named "%3".)"_L1.arg(
1501 realTypeName, uri.toString(), elementName);
1502 if (elementName == u"qml")
1503 errorMessage +=
" To load the type \"%1\", drop the \".qml\" extension."_L1.arg(realTypeName);
1504 reportError(std::move(errorMessage));
1506 m_inlineComponentName = std::make_unique<QString>(std::move(elementName));
1509 }
else if (type.isSingleton() || type.isCompositeSingleton()) {
1510 reportError(QLatin1String(R"(%1 is a singleton, and cannot be loaded)").arg(typeName.toString()));
1512 reportError(QLatin1String(
"Could not load %1, as the type is uncreatable").arg(typeName.toString()));
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1536void QQmlComponent::create(QQmlIncubator &incubator, QQmlContext *context, QQmlContext *forContext)
1541 context = d->m_engine->rootContext();
1543 QQmlRefPointer<QQmlContextData> contextData = QQmlContextData::get(context);
1544 QQmlRefPointer<QQmlContextData> forContextData =
1545 forContext ? QQmlContextData::get(forContext) : contextData;
1547 if (!contextData->isValid()) {
1548 qWarning(
"QQmlComponent: Cannot create a component in an invalid context");
1552 if (contextData->engine() != d->m_engine) {
1553 qWarning(
"QQmlComponent: Must create component in context from the same QQmlEngine");
1558 qWarning(
"QQmlComponent: Component is not ready");
1563 QExplicitlySharedDataPointer<QQmlIncubatorPrivate> p(incubator.d);
1565 if (d->loadedType().isValid()) {
1569 p->incubateCppBasedComponent(
this, context);
1573 QQmlEnginePrivate *enginePriv = QQmlEnginePrivate::get(d->m_engine);
1575 p->compilationUnit = d->m_compilationUnit;
1576 p->enginePriv = enginePriv;
1577 p->creator.reset(
new QQmlObjectCreator(
1578 contextData, d->m_compilationUnit, d->m_creationContext,
1579 d->m_inlineComponentName ? *d->m_inlineComponentName : QString(), p.data()));
1580 p->subComponentToCreate = d->m_start;
1582 enginePriv->incubate(incubator, forContextData);
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608void QQmlComponent::setInitialProperties(QObject *object,
const QVariantMap &properties)
1611 for (
auto it = properties.constBegin(); it != properties.constEnd(); ++it) {
1612 if (it.key().contains(u'.')) {
1613 auto segments = it.key().split(u'.');
1614 QString description = u"Setting initial properties failed: Cannot initialize nested "_s
1616 if (segments.size() >= 2) {
1617 QString s = u" To set %1.%2 as an initial property, create %1, set its "_s
1618 u"property %2, and pass %1 as an initial property."_s;
1619 description += s.arg(segments[0], segments[1]);
1622 error.setUrl(url());
1623 error.setDescription(description);
1624 qmlWarning(object, error);
1627 d->setInitialProperty(object, it.key(), it.value());
1632
1633
1634
1635
1636
1637
1638void QQmlComponentPrivate::incubateObject(
1639 QQmlIncubator *incubationTask,
1640 QQmlComponent *component,
1642 const QQmlRefPointer<QQmlContextData> &context,
1643 const QQmlRefPointer<QQmlContextData> &forContext)
1645 QQmlIncubatorPrivate *incubatorPriv = QQmlIncubatorPrivate::get(incubationTask);
1646 QQmlEnginePrivate *enginePriv = QQmlEnginePrivate::get(engine);
1647 QQmlComponentPrivate *componentPriv = QQmlComponentPrivate::get(component);
1649 incubatorPriv->compilationUnit = componentPriv->m_compilationUnit;
1650 incubatorPriv->enginePriv = enginePriv;
1651 incubatorPriv->creator.reset(
new QQmlObjectCreator(
1652 context, componentPriv->m_compilationUnit, componentPriv->m_creationContext,
1653 m_inlineComponentName ? *m_inlineComponentName : QString()));
1655 if (m_start == -1) {
1656 if (
const QString *icName = componentPriv->m_inlineComponentName.get()) {
1657 m_start = m_compilationUnit->inlineComponentId(*icName);
1658 Q_ASSERT(m_start > 0);
1661 incubatorPriv->subComponentToCreate = componentPriv->m_start;
1663 enginePriv->incubate(*incubationTask, forContext);
1674#define QmlIncubatorObjectMembers(class, Member)
1675 Member(class, HeapValue, HeapValue, valuemapOrObject)
1676 Member(class, HeapValue, HeapValue, statusChanged)
1677 Member(class, Pointer, QmlContext *, qmlContext)
1678 Member(class, NoMark, QQmlComponentIncubator *, incubator)
1679 Member(class, NoMark, QV4QPointer<QObject>, parent)
1682 DECLARE_MARKOBJECTS(QmlIncubatorObject)
1684 void init(QQmlIncubator::IncubationMode = QQmlIncubator::Asynchronous);
1685 inline void destroy();
1715 incubatorObject.set(inc->internalClass->engine, inc);
1719 QV4::Scope scope(incubatorObject.engine());
1720 QV4::Scoped<QV4::QmlIncubatorObject> i(scope, incubatorObject.as<QV4::QmlIncubatorObject>());
1721 i->statusChanged(s);
1725 QV4::Scope scope(incubatorObject.engine());
1726 QV4::Scoped<QV4::QmlIncubatorObject> i(scope, incubatorObject.as<QV4::QmlIncubatorObject>());
1727 auto d = QQmlIncubatorPrivate::get(
this);
1728 i->setInitialState(o, d->requiredProperties());
1738 me->setParent(parent);
1739 typedef QQmlPrivate::AutoParentFunction APF;
1740 QList<APF> functions = QQmlMetaType::parentFunctions();
1742 bool needParent =
false;
1743 for (
int ii = 0; ii < functions.size(); ++ii) {
1744 QQmlPrivate::AutoParentResult res = functions.at(ii)(me, parent);
1745 if (res == QQmlPrivate::Parented) {
1748 }
else if (res == QQmlPrivate::IncompatibleParent) {
1753 qmlWarning(me) <<
"Created graphical object was not placed in the graphics scene.";
1758
1759
1760
1761
1762
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
1800void QQmlComponentPrivate::setInitialProperties(
1801 QV4::ExecutionEngine *engine, QV4::QmlContext *qmlContext,
const QV4::Value &o,
1802 const QV4::Value &v, RequiredProperties *requiredProperties, QObject *createdComponent,
1803 const QQmlObjectCreator *creator)
1805 QV4::Scope scope(engine);
1806 QV4::ScopedObject object(scope);
1807 QV4::ScopedObject valueMap(scope, v);
1808 QV4::ObjectIterator it(scope, valueMap, QV4::ObjectIterator::EnumerableOnly);
1809 QV4::ScopedString name(scope);
1810 QV4::ScopedValue val(scope);
1811 if (engine->hasException)
1815 QV4::ScopedStackFrame frame(scope, qmlContext ? qmlContext : engine->scriptContext());
1818 name = it.nextPropertyNameAsString(val);
1822 const QStringList properties = name->toQString().split(QLatin1Char(
'.'));
1823 bool isTopLevelProperty = properties.size() == 1;
1824 for (
int i = 0; i < properties.size() - 1; ++i) {
1825 name = engine->newString(properties.at(i));
1826 object = object->get(name);
1827 if (engine->hasException || !object) {
1831 if (engine->hasException) {
1832 qmlWarning(createdComponent, engine->catchExceptionAsQmlError());
1837 error.setUrl(qmlContext ? qmlContext->qmlContext()->url() : QUrl());
1838 error.setDescription(QLatin1String(
"Cannot resolve property \"%1\".")
1839 .arg(properties.join(u'.')));
1840 qmlWarning(createdComponent, error);
1843 const QString lastProperty = properties.last();
1844 name = engine->newString(lastProperty);
1845 object->put(name, val);
1846 if (engine->hasException) {
1847 qmlWarning(createdComponent, engine->catchExceptionAsQmlError());
1849 }
else if (isTopLevelProperty && requiredProperties) {
1850 auto prop = removePropertyFromRequired(createdComponent, name->toQString(),
1851 requiredProperties, engine->qmlEngine());
1854 removePendingQPropertyBinding(object, lastProperty, creator);
1857 engine->hasException =
false;
1860QQmlError QQmlComponentPrivate::unsetRequiredPropertyToQQmlError(
const RequiredPropertyInfo &unsetRequiredProperty)
1863 QString description = QLatin1String(
"Required property %1 was not initialized").arg(unsetRequiredProperty.propertyName);
1864 switch (unsetRequiredProperty.aliasesToRequired.size()) {
1868 const auto info = unsetRequiredProperty.aliasesToRequired.first();
1869 description += QLatin1String(
"\nIt can be set via the alias property %1 from %2\n").arg(info.propertyName, info.fileUrl.toString());
1873 description += QLatin1String(
"\nIt can be set via one of the following alias properties:");
1874 for (
auto aliasInfo: unsetRequiredProperty.aliasesToRequired) {
1875 description += QLatin1String(
"\n- %1 (%2)").arg(aliasInfo.propertyName, aliasInfo.fileUrl.toString());
1877 description += QLatin1Char(
'\n');
1879 error.setDescription(description);
1880 error.setUrl(unsetRequiredProperty.fileUrl);
1881 error.setLine(qmlConvertSourceCoordinate<quint32,
int>(
1882 unsetRequiredProperty.location.line()));
1883 error.setColumn(qmlConvertSourceCoordinate<quint32,
int>(
1884 unsetRequiredProperty.location.column()));
1888#if QT_DEPRECATED_SINCE(6
, 3
)
1890
1891
1892void QQmlComponent::createObject(QQmlV4FunctionPtr args)
1895 Q_ASSERT(d->m_engine);
1898 qmlWarning(
this) <<
"Unsuitable arguments passed to createObject(). The first argument should "
1899 "be a QObject* or null, and the second argument should be a JavaScript "
1900 "object or a QVariantMap";
1902 QObject *parent =
nullptr;
1903 QV4::ExecutionEngine *v4 = args->v4engine();
1904 QV4::Scope scope(v4);
1905 QV4::ScopedValue valuemap(scope, QV4::Value::undefinedValue());
1907 if (args->length() >= 1) {
1908 QV4::Scoped<QV4::QObjectWrapper> qobjectWrapper(scope, (*args)[0]);
1910 parent = qobjectWrapper->object();
1913 if (args->length() >= 2) {
1914 QV4::ScopedValue v(scope, (*args)[1]);
1915 if (!v->as<QV4::Object>() || v->as<QV4::ArrayObject>()) {
1916 qmlWarning(
this) << tr(
"createObject: value is not an object");
1917 args->setReturnValue(QV4::Encode::null());
1923 QQmlContext *ctxt = creationContext();
1924 if (!ctxt) ctxt = d->m_engine->rootContext();
1926 QObject *rv = beginCreate(ctxt);
1929 args->setReturnValue(QV4::Encode::null());
1933 QQmlComponent_setQmlParent(rv, parent);
1935 QV4::ScopedValue object(scope, QV4::QObjectWrapper::wrap(v4, rv));
1936 Q_ASSERT(object->isObject());
1938 if (!valuemap->isUndefined()) {
1939 QV4::Scoped<QV4::QmlContext> qmlContext(scope, v4->qmlContext());
1940 QQmlComponentPrivate::setInitialProperties(
1941 v4, qmlContext, object, valuemap, d->m_state.requiredProperties(), rv,
1942 d->m_state.creator());
1944 if (d->m_state.hasUnsetRequiredProperties()) {
1945 QList<QQmlError> errors;
1946 for (
const auto &requiredProperty: std::as_const(*d->m_state.requiredProperties())) {
1947 errors.push_back(QQmlComponentPrivate::unsetRequiredPropertyToQQmlError(requiredProperty));
1949 qmlWarning(rv, errors);
1950 args->setReturnValue(QV4::Encode::null());
1955 d->completeCreate();
1957 Q_ASSERT(QQmlData::get(rv));
1958 QQmlData::get(rv)->explicitIndestructibleSet =
false;
1959 QQmlData::get(rv)->indestructible =
false;
1961 args->setReturnValue(object->asReturnedValue());
1966
1967
1968QObject *QQmlComponent::createObject(QObject *parent,
const QVariantMap &properties)
1971 Q_ASSERT(d->m_engine);
1972 QObject *rv = d->createWithProperties(parent, properties, creationContext(),
1973 QQmlComponentPrivate::CreateWarnAboutRequiredProperties,
1976 QQmlData *qmlData = QQmlData::get(rv);
1978 qmlData->explicitIndestructibleSet =
false;
1979 qmlData->indestructible =
false;
1985
1986
1987
1988
1989
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
2040
2041
2042void QQmlComponent::incubateObject(QQmlV4FunctionPtr args)
2045 Q_ASSERT(d->m_engine);
2048 QV4::ExecutionEngine *v4 = args->v4engine();
2049 QV4::Scope scope(v4);
2051 QObject *parent =
nullptr;
2052 QV4::ScopedValue valuemap(scope, QV4::Value::undefinedValue());
2053 QQmlIncubator::IncubationMode mode = QQmlIncubator::Asynchronous;
2055 if (args->length() >= 1) {
2056 QV4::Scoped<QV4::QObjectWrapper> qobjectWrapper(scope, (*args)[0]);
2058 parent = qobjectWrapper->object();
2061 if (args->length() >= 2) {
2062 QV4::ScopedValue v(scope, (*args)[1]);
2064 }
else if (!v->as<QV4::Object>() || v->as<QV4::ArrayObject>()) {
2065 qmlWarning(
this) << tr(
"createObject: value is not an object");
2066 args->setReturnValue(QV4::Encode::null());
2073 if (args->length() >= 3) {
2074 QV4::ScopedValue val(scope, (*args)[2]);
2075 quint32 v = val->toUInt32();
2077 mode = QQmlIncubator::Asynchronous;
2079 mode = QQmlIncubator::AsynchronousIfNested;
2082 QQmlComponentExtension *e = componentExtension(args->v4engine());
2084 QV4::Scoped<QV4::QmlIncubatorObject> r(scope, v4->memoryManager->allocate<QV4::QmlIncubatorObject>(mode));
2085 QV4::ScopedObject p(scope, e->incubationProto.value());
2086 r->setPrototypeOf(p);
2088 if (!valuemap->isUndefined())
2089 r->d()->valuemapOrObject.set(scope.engine, valuemap);
2090 r->d()->qmlContext.set(scope.engine, v4->qmlContext());
2091 r->d()->parent = parent;
2093 QQmlIncubator *incubator = r->d()->incubator;
2094 create(*incubator, creationContext());
2096 if (incubator->status() == QQmlIncubator::Null) {
2097 args->setReturnValue(QV4::Encode::null());
2099 args->setReturnValue(r.asReturnedValue());
2104void QQmlComponentPrivate::initializeObjectWithInitialProperties(QV4::QmlContext *qmlContext,
const QV4::Value &valuemap, QObject *toCreate, RequiredProperties *requiredProperties)
2106 QV4::ExecutionEngine *v4engine = m_engine->handle();
2107 QV4::Scope scope(v4engine);
2109 QV4::ScopedValue object(scope, QV4::QObjectWrapper::wrap(v4engine, toCreate));
2110 Q_ASSERT(object->as<QV4::Object>());
2112 if (!valuemap.isUndefined()) {
2113 setInitialProperties(
2114 v4engine, qmlContext, object, valuemap, requiredProperties, toCreate, m_state.creator());
2118QQmlComponentExtension::QQmlComponentExtension(QV4::ExecutionEngine *v4)
2120 QV4::Scope scope(v4);
2121 QV4::ScopedObject proto(scope, v4->newObject());
2122 proto->defineAccessorProperty(QStringLiteral(
"onStatusChanged"),
2123 QV4::QmlIncubatorObject::method_get_statusChanged, QV4::QmlIncubatorObject::method_set_statusChanged);
2124 proto->defineAccessorProperty(QStringLiteral(
"status"), QV4::QmlIncubatorObject::method_get_status,
nullptr);
2125 proto->defineAccessorProperty(QStringLiteral(
"object"), QV4::QmlIncubatorObject::method_get_object,
nullptr);
2126 proto->defineDefaultProperty(QStringLiteral(
"forceCompletion"), QV4::QmlIncubatorObject::method_forceCompletion);
2128 incubationProto.set(v4, proto);
2131QV4::ReturnedValue
QV4::
QmlIncubatorObject::method_get_object(
const FunctionObject *b,
const Value *thisObject,
const Value *,
int)
2133 QV4::Scope scope(b);
2134 QV4::Scoped<QmlIncubatorObject> o(scope, thisObject->as<QmlIncubatorObject>());
2138 return QV4::QObjectWrapper::wrap(scope.engine, o->d()->incubator->object());
2141QV4::ReturnedValue
QV4::
QmlIncubatorObject::method_forceCompletion(
const FunctionObject *b,
const Value *thisObject,
const Value *,
int)
2143 QV4::Scope scope(b);
2144 QV4::Scoped<QmlIncubatorObject> o(scope, thisObject->as<QmlIncubatorObject>());
2148 o->d()->incubator->forceCompletion();
2153QV4::ReturnedValue
QV4::
QmlIncubatorObject::method_get_status(
const FunctionObject *b,
const Value *thisObject,
const Value *,
int)
2155 QV4::Scope scope(b);
2156 QV4::Scoped<QmlIncubatorObject> o(scope, thisObject->as<QmlIncubatorObject>());
2160 return QV4::Encode(o->d()->incubator->status());
2163QV4::ReturnedValue
QV4::
QmlIncubatorObject::method_get_statusChanged(
const FunctionObject *b,
const Value *thisObject,
const Value *,
int)
2165 QV4::Scope scope(b);
2166 QV4::Scoped<QmlIncubatorObject> o(scope, thisObject->as<QmlIncubatorObject>());
2170 return QV4::Encode(o->d()->statusChanged);
2173QV4::ReturnedValue
QV4::
QmlIncubatorObject::method_set_statusChanged(
const FunctionObject *b,
const Value *thisObject,
const Value *argv,
int argc)
2175 QV4::Scope scope(b);
2176 QV4::Scoped<QmlIncubatorObject> o(scope, thisObject->as<QmlIncubatorObject>());
2180 o->d()->statusChanged.set(scope.engine, argv[0]);
2185QQmlComponentExtension::~QQmlComponentExtension()
2189void QV4::Heap::QmlIncubatorObject::init(QQmlIncubator::IncubationMode m)
2192 valuemapOrObject.set(internalClass->engine, QV4::Value::undefinedValue());
2193 statusChanged.set(internalClass->engine, QV4::Value::undefinedValue());
2195 qmlContext.set(internalClass->engine,
nullptr);
2196 incubator =
new QQmlComponentIncubator(
this, m);
2199void QV4::Heap::QmlIncubatorObject::destroy() {
2207 QQmlComponent_setQmlParent(o, d()->parent);
2209 if (!d()->valuemapOrObject.isUndefined()) {
2210 QV4::ExecutionEngine *v4 = engine();
2211 QV4::Scope scope(v4);
2212 QV4::ScopedObject obj(scope, QV4::QObjectWrapper::wrap(v4, o));
2213 QV4::Scoped<QV4::QmlContext> qmlCtxt(scope, d()->qmlContext);
2214 QQmlComponentPrivate::setInitialProperties(
2215 v4, qmlCtxt, obj, d()->valuemapOrObject, requiredProperties, o,
2216 QQmlIncubatorPrivate::get(d()->incubator)->creator.data());
2222 QV4::Scope scope(engine());
2224 QObject *object = d()->incubator->object();
2226 if (s == QQmlIncubator::Ready) {
2229 d()->valuemapOrObject.set(scope.engine, QV4::QObjectWrapper::wrap(scope.engine, object));
2231 QQmlData *ddata = QQmlData::get(object);
2233 ddata->explicitIndestructibleSet =
false;
2234 ddata->indestructible =
false;
2237 QV4::ScopedFunctionObject f(scope, d()->statusChanged);
2239 QV4::JSCallArguments jsCallData(scope, 1);
2240 *jsCallData.thisObject =
this;
2241 jsCallData.args[0] = QV4::Value::fromUInt32(s);
2242 f->call(jsCallData);
2243 if (scope.hasException()) {
2244 QQmlError error = scope.engine->catchExceptionAsQmlError();
2245 QQmlEnginePrivate::warning(QQmlEnginePrivate::get(scope.engine->qmlEngine()), error);
2249 if (s != QQmlIncubator::Loading)
2250 d()->incubator->incubatorObject.clear();
2253#undef INITIALPROPERTIES_SOURCE
2257#include "moc_qqmlcomponent.cpp"
2258#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)