Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qqmlcomponent.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 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
4#include "qqmlcomponent.h"
5#include "qqmlcomponent_p.h"
7
8#include "qqmlengine_p.h"
9#include "qqmlvme_p.h"
10#include "qqml.h"
11#include "qqmlengine.h"
12#include "qqmlincubator.h"
13#include "qqmlincubator_p.h"
14#include <private/qqmljavascriptexpression_p.h>
15#include <private/qqmlsourcecoordinate_p.h>
16
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>
23
24#include <QDir>
25#include <QStack>
26#include <QStringList>
27#include <QThreadStorage>
28#include <QtCore/qdebug.h>
29#include <QtCore/qloggingcategory.h>
30#include <qqmlinfo.h>
31
32namespace {
33 Q_CONSTINIT thread_local int creationDepth = 0;
34}
35
36Q_LOGGING_CATEGORY(lcQmlComponentGeneral, "qt.qml.qmlcomponent")
37
39
40class QQmlComponentExtension : public QV4::ExecutionEngine::Deletable
41{
42public:
45
47};
49
275{
276 Q_Q(QQmlComponent);
277
279
281 typeData.reset();
282 progress = 1.0;
283
284 emit q->statusChanged(q->status());
285 emit q->progressChanged(progress);
286}
287
289{
290 Q_Q(QQmlComponent);
291
292 progress = p;
293
294 emit q->progressChanged(p);
295}
296
298{
299 url = data->finalUrl();
300 compilationUnit.reset(data->compilationUnit());
301
302 if (!compilationUnit) {
303 Q_ASSERT(data->isError());
304 state.errors.clear();
305 state.appendErrors(data->errors());
306 }
307}
308
310{
312}
313
315{
316 if (typeData) {
318 typeData.reset();
319 }
320
322 loadedType = {};
323 inlineComponentName.reset();
324}
325
327{
328 if (!engine) {
329 // ###Qt6: In Qt 6, it should be impossible for users to create a QQmlComponent without an engine, and we can remove this check
330 qWarning("QQmlComponent: Must provide an engine before calling create");
331 return nullptr;
332 }
333 if (!context)
335 return q->beginCreate(context);
336}
337
339 QV4::Value *object, const QString &propertyName, QQmlObjectCreator *creator)
340{
341 if (!creator)
342 return;
343
345 if (!wrapper)
346 return;
347
348 QObject *o = wrapper->object();
349 if (!o)
350 return;
351
352 if (QQmlData *ddata = QQmlData::get(o)) {
353 const QQmlPropertyData *propData = ddata->propertyCache->property(
354 propertyName, o, ddata->outerContext);
355 if (propData && propData->isBindable())
356 creator->removePendingBinding(o, propData->coreIndex());
357 return;
358 }
359
360 const QMetaObject *meta = o->metaObject();
361 Q_ASSERT(meta);
362 const int index = meta->indexOfProperty(propertyName.toUtf8());
363 if (index != -1 && meta->property(index).isBindable())
364 creator->removePendingBinding(o, index);
365}
366
368 QObject *base, const QString &name, const QVariant &value)
369{
370 const QStringList properties = name.split(u'.');
371
372 if (properties.size() > 1) {
373 QV4::Scope scope(engine->handle());
376
377 for (int i = 0; i < properties.size() - 1; ++i) {
378 segment = scope.engine->newString(properties.at(i));
379 object = object->get(segment);
380 if (scope.engine->hasException)
381 break;
382 }
383 const QString lastProperty = properties.last();
384 segment = scope.engine->newString(lastProperty);
385 object->put(segment, scope.engine->metaTypeToJS(value.metaType(), value.constData()));
386 if (scope.engine->hasException) {
388 scope.engine->hasException = false;
389 return false;
390 }
391
392 removePendingQPropertyBinding(object, lastProperty, state.creator());
393 return true;
394 }
395
396 QQmlProperty prop;
400 else
401 prop = QQmlProperty(base, name, engine);
403 const bool isValid = prop.isValid();
404 if (isValid && privProp->writeValueProperty(value, {})) {
405 if (prop.isBindable()) {
407 creator->removePendingBinding(prop.object(), prop.index());
408 }
409 } else {
411 error.setUrl(url);
412 if (isValid) {
413 error.setDescription(QStringLiteral("Could not set initial property %1").arg(name));
414 } else {
415 error.setDescription(QStringLiteral("Setting initial properties failed: "
416 "%2 does not have a property called %1")
418 }
420 return false;
421 }
422
423 return true;
424
425}
426
432{
433}
434
439{
440 Q_D(QQmlComponent);
441
442 if (d->state.isCompletePending()) {
443 qWarning("QQmlComponent: Component destroyed while completion pending");
444
445 if (isError()) {
446 qWarning() << "This may have been caused by one of the following errors:";
447 for (const QQmlComponentPrivate::AnnotatedQmlError &e : std::as_const(d->state.errors))
448 qWarning().nospace().noquote() << QLatin1String(" ") << e.error;
449 }
450
451 // we might not have the creator anymore if the engine is gone
452 if (d->state.hasCreator())
453 d->completeCreate();
454 }
455
456 if (d->typeData) {
457 d->typeData->unregisterCallback(d);
458 d->typeData.reset();
459 }
460}
461
480{
481 Q_D(const QQmlComponent);
482
483 if (d->typeData)
484 return Loading;
485 else if (!d->state.errors.isEmpty())
486 return Error;
487 else if (d->engine && (d->compilationUnit || d->loadedType.isValid()))
488 return Ready;
489 else
490 return Null;
491}
492
497{
498 return status() == Null;
499}
500
505{
506 return status() == Ready;
507}
508
513{
514 return status() == Error;
515}
516
521{
522 return status() == Loading;
523}
524
532{
533 Q_D(const QQmlComponent);
534 return d->isBound();
535}
536
549{
550 Q_D(const QQmlComponent);
551 return d->progress;
552}
553
574{
575 Q_D(QQmlComponent);
576 d->engine = engine;
578 d->state.clear();
579 d->engine = nullptr;
580 });
581}
582
592 : QQmlComponent(engine, url, QQmlComponent::PreferSynchronous, parent)
593{
594}
595
608{
609 Q_D(QQmlComponent);
610 d->loadUrl(url, mode);
611}
612
623 : QQmlComponent(engine, uri, typeName, QQmlComponent::PreferSynchronous, parent)
624{
625
626}
627
639{
641}
642
651 : QQmlComponent(engine, fileName, QQmlComponent::PreferSynchronous, parent)
652{
653}
654
665{
666 Q_D(QQmlComponent);
667 if (fileName.startsWith(u':'))
668 d->loadUrl(QUrl(QLatin1String("qrc") + fileName), mode);
671 else
672 d->loadUrl(QUrl(fileName), mode);
673}
674
679 int start, QObject *parent)
681{
682 Q_D(QQmlComponent);
683 d->compilationUnit.reset(compilationUnit);
684 d->start = start;
685 d->url = compilationUnit->finalUrl();
686 d->progress = 1.0;
687}
688
695{
696 Q_D(QQmlComponent);
697
698 if (!d->engine) {
699 // ###Qt6: In Qt 6, it should be impossible for users to create a QQmlComponent without an engine, and we can remove this check
700 qWarning("QQmlComponent: Must provide an engine before calling setData");
701 return;
702 }
703
704 d->clear();
705
706 d->url = url;
707
709
710 if (typeData->isCompleteOrError()) {
711 d->fromTypeData(typeData);
712 } else {
713 d->typeData = typeData;
714 d->typeData->registerCallback(d);
715 }
716
717 d->progress = 1.0;
719 emit progressChanged(d->progress);
720}
721
727{
728 Q_D(const QQmlComponent);
729 if (!d->creationContext.isNull())
730 return d->creationContext->asQQmlContext();
731
732 return qmlContext(this);
733}
734
741{
742 Q_D(const QQmlComponent);
743 return d->engine;
744}
745
752{
753 Q_D(QQmlComponent);
754 d->loadUrl(url);
755}
756
764{
765 Q_D(QQmlComponent);
766 d->loadUrl(url, mode);
767}
768
770{
771 Q_Q(QQmlComponent);
772 clear();
773
774 if (newUrl.isRelative()) {
775 // The new URL is a relative URL like QUrl("main.qml").
776 url = engine->baseUrl().resolved(QUrl(newUrl.toString()));
777 } else if (engine->baseUrl().isLocalFile() && newUrl.isLocalFile() && !QDir::isAbsolutePath(newUrl.toLocalFile())) {
778 // The new URL is a file on disk but it's a relative path; e.g.:
779 // QUrl::fromLocalFile("main.qml") or QUrl("file:main.qml")
780 // We need to remove the scheme so that it becomes a relative URL with a relative path:
781 QUrl fixedUrl(newUrl);
782 fixedUrl.setScheme(QString());
783 // Then, turn it into an absolute URL with an absolute path by resolving it against the engine's baseUrl().
784 // This is a compatibility hack for QTBUG-58837.
785 url = engine->baseUrl().resolved(fixedUrl);
786 } else {
787 url = newUrl;
788 }
789
790 if (newUrl.isEmpty()) {
792 error.setDescription(QQmlComponent::tr("Invalid empty URL"));
793 state.errors.emplaceBack(error);
794 return;
795 }
796
797 if (progress != 0.0) {
798 progress = 0.0;
799 emit q->progressChanged(progress);
800 }
801
806
807 if (data->isCompleteOrError()) {
809 progress = 1.0;
810 } else {
811 typeData = data;
813 progress = data->progress();
814 }
815
816 emit q->statusChanged(q->status());
817 if (progress != 0.0)
818 emit q->progressChanged(progress);
819}
820
826{
827 Q_D(const QQmlComponent);
829 errors.reserve(d->state.errors.size());
830 for (const QQmlComponentPrivate::AnnotatedQmlError &annotated : d->state.errors)
831 errors.emplaceBack(annotated.error);
832 return errors;
833}
834
851{
852 Q_D(const QQmlComponent);
853 QString ret;
854 if(!isError())
855 return ret;
856 for (const QQmlComponentPrivate::AnnotatedQmlError &annotated : d->state.errors) {
857 const QQmlError &e = annotated.error;
858 ret += e.url().toString() + QLatin1Char(':') +
859 QString::number(e.line()) + QLatin1Char(' ') +
860 e.description() + QLatin1Char('\n');
861 }
862 return ret;
863}
864
876{
877 Q_D(const QQmlComponent);
878 return d->url;
879}
880
885 : QObject(dd, parent)
886{
887}
888
906{
907 Q_D(QQmlComponent);
908 return d->createWithProperties(nullptr, QVariantMap {}, context);
909}
910
927{
928 Q_D(QQmlComponent);
929 return d->createWithProperties(nullptr, initialProperties, context);
930}
931
932static void QQmlComponent_setQmlParent(QObject *me, QObject *parent); // forward declaration
933
938{
939 Q_Q(QQmlComponent);
940
942 if (!rv) {
943 if (state.isCompletePending()) {
944 // overridden completCreate might assume that
945 // the object has actually been created
946 ++creationDepth;
948 complete(ep, &state);
949 --creationDepth;
950 }
951 return nullptr;
952 }
953
954 QQmlComponent_setQmlParent(rv, parent); // internally checks if parent is nullptr
955
956 q->setInitialProperties(rv, properties);
957 q->completeCreate();
958
960 if (behavior == CreateWarnAboutRequiredProperties) {
961 for (const auto &unsetRequiredProperty : std::as_const(*state.requiredProperties())) {
962 const QQmlError error = unsetRequiredPropertyToQQmlError(unsetRequiredProperty);
963 qmlWarning(rv, error);
964 }
965 }
966 delete rv;
967 rv = nullptr;
968 }
969 return rv;
970}
971
1001{
1002 Q_D(QQmlComponent);
1004 return d->beginCreate(QQmlContextData::get(context));
1005}
1006
1008{
1009 Q_Q(QQmlComponent);
1010 auto cleanup = qScopeGuard([this] {
1011 if (!state.errors.isEmpty() && lcQmlComponentGeneral().isDebugEnabled()) {
1012 for (const auto &e : std::as_const(state.errors)) {
1013 qCDebug(lcQmlComponentGeneral) << "QQmlComponent: " << e.error.toString();
1014 }
1015 }
1016 });
1017 if (!context) {
1018 qWarning("QQmlComponent: Cannot create a component in a null context");
1019 return nullptr;
1020 }
1021
1022 if (!context->isValid()) {
1023 qWarning("QQmlComponent: Cannot create a component in an invalid context");
1024 return nullptr;
1025 }
1026
1027 if (context->engine() != engine) {
1028 qWarning("QQmlComponent: Must create component in context from the same QQmlEngine");
1029 return nullptr;
1030 }
1031
1032 if (state.isCompletePending()) {
1033 qWarning("QQmlComponent: Cannot create new component instance before completing the previous");
1034 return nullptr;
1035 }
1036
1037 // filter out temporary errors as they do not really affect component's
1038 // state (they are not part of the document compilation)
1039 state.errors.erase(std::remove_if(state.errors.begin(), state.errors.end(),
1041 return e.isTransient;
1042 }),
1043 state.errors.end());
1045
1046 if (!q->isReady()) {
1047 qWarning("QQmlComponent: Component is not ready");
1048 return nullptr;
1049 }
1050
1051 // Do not create infinite recursion in object creation
1052 static const int maxCreationDepth = 10;
1053 if (creationDepth >= maxCreationDepth) {
1054 qWarning("QQmlComponent: Component creation is recursing - aborting");
1055 return nullptr;
1056 }
1057
1059
1060 enginePriv->inProgressCreations++;
1061 state.errors.clear();
1063
1064 QObject *rv = nullptr;
1065
1066 if (!loadedType.isValid()) {
1067 enginePriv->referenceScarceResources();
1069
1071 if (const QString *icName = inlineComponentName.get()) {
1073 if (start == -1)
1075 Q_ASSERT(start > 0);
1076 } else {
1078 }
1079
1080 rv = state.creator()->create(start, nullptr, nullptr, flags);
1081 if (!rv)
1083 enginePriv->dereferenceScarceResources();
1084 } else {
1087 for (int i = 0, propertyCount = propertyCache->propertyCount(); i < propertyCount; ++i) {
1088 if (const QQmlPropertyData *propertyData = propertyCache->property(i); propertyData->isRequired()) {
1091 info.propertyName = propertyData->name(rv);
1092 state.addPendingRequiredProperty(rv, propertyData, info);
1093 }
1094 }
1095 }
1096
1097 if (rv) {
1098 QQmlData *ddata = QQmlData::get(rv);
1099 Q_ASSERT(ddata);
1100 // top-level objects should never get JS ownership.
1101 // if JS ownership is needed this needs to be explicitly undone (like in createObject())
1102 ddata->indestructible = true;
1103 ddata->explicitIndestructibleSet = true;
1104 ddata->rootObjectInCreation = false;
1105 }
1106
1107 return rv;
1108}
1109
1111 QObject *object, DeferredState *deferredState)
1112{
1113 QQmlData *ddata = QQmlData::get(object);
1114 Q_ASSERT(!ddata->deferredData.isEmpty());
1115
1116 deferredState->reserve(ddata->deferredData.size());
1117
1118 for (QQmlData::DeferredData *deferredData : std::as_const(ddata->deferredData)) {
1119 enginePriv->inProgressCreations++;
1120
1123
1124 auto creator = state.initCreator(
1125 deferredData->context->parent(),
1126 deferredData->compilationUnit,
1128
1129 if (!creator->populateDeferredProperties(object, deferredData))
1131 deferredData->bindings.clear();
1132
1133 deferredState->push_back(std::move(state));
1134 }
1135}
1136
1138{
1139 for (ConstructionState &state : *deferredState)
1140 complete(enginePriv, &state);
1141}
1142
1144{
1145 if (state->isCompletePending()) {
1147 state->creator()->finalize(interrupt);
1148
1149 state->setCompletePending(false);
1150
1151 enginePriv->inProgressCreations--;
1152
1153 if (0 == enginePriv->inProgressCreations) {
1154 while (enginePriv->erroredBindings) {
1155 enginePriv->warning(enginePriv->erroredBindings->removeError());
1156 }
1157 }
1158 }
1159}
1160
1179 QObject *createdComponent, const QString &name, RequiredProperties *requiredProperties,
1180 QQmlEngine *engine, bool *wasInRequiredProperties)
1181{
1182 Q_ASSERT(requiredProperties);
1183 QQmlProperty prop(createdComponent, name, engine);
1184 auto privProp = QQmlPropertyPrivate::get(prop);
1185 if (prop.isValid()) {
1186 // resolve outstanding required properties
1187 const QQmlPropertyData *targetProp = &privProp->core;
1188 if (targetProp->isAlias()) {
1189 auto target = createdComponent;
1190 QQmlPropertyIndex originalIndex(targetProp->coreIndex());
1191 QQmlPropertyIndex propIndex;
1192 QQmlPropertyPrivate::findAliasTarget(target, originalIndex, &target, &propIndex);
1194 Q_ASSERT(data && data->propertyCache);
1195 targetProp = data->propertyCache->property(propIndex.coreIndex());
1196 } else {
1197 // we need to get the pointer from the property cache instead of directly using
1198 // targetProp else the lookup will fail
1199 QQmlData *data = QQmlData::get(createdComponent);
1200 Q_ASSERT(data && data->propertyCache);
1201 targetProp = data->propertyCache->property(targetProp->coreIndex());
1202 }
1203 auto it = requiredProperties->find({createdComponent, targetProp});
1204 if (it != requiredProperties->end()) {
1205 if (wasInRequiredProperties)
1206 *wasInRequiredProperties = true;
1207 requiredProperties->erase(it);
1208 } else {
1209 if (wasInRequiredProperties)
1210 *wasInRequiredProperties = false;
1211 }
1212 }
1213 return prop;
1214}
1215
1227{
1228 Q_D(QQmlComponent);
1229
1230 d->completeCreate();
1231}
1232
1234{
1236 for (const auto& unsetRequiredProperty: std::as_const(*state.requiredProperties())) {
1237 QQmlError error = unsetRequiredPropertyToQQmlError(unsetRequiredProperty);
1239 }
1240 }
1241 if (loadedType.isValid()) {
1242 /*
1243 We can directly set completePending to false, as finalize is only concerned
1244 with setting up pending bindings, but that cannot happen here, as we're
1245 dealing with a pure C++ type, which cannot have pending bindings
1246 */
1249 } else if (state.isCompletePending()) {
1250 ++creationDepth;
1252 complete(ep, &state);
1253 --creationDepth;
1254 }
1255}
1256
1258: QObject(parent), m_prev(nullptr), m_next(nullptr)
1259{
1260}
1261
1263{
1264 if (m_prev) *m_prev = m_next;
1265 if (m_next) m_next->m_prev = m_prev;
1266 m_prev = nullptr;
1267 m_next = nullptr;
1268}
1269
1274{
1276
1278 if (!engine)
1279 return a;
1280
1282 if (p->activeObjectCreator) { // XXX should only be allowed during begin
1283 a->insertIntoList(p->activeObjectCreator->componentAttachment());
1284 } else {
1286 Q_ASSERT(d);
1287 Q_ASSERT(d->context);
1288 d->context->addComponentAttached(a);
1289 }
1290
1291 return a;
1292}
1293
1313{
1314 Q_D(QQmlComponent);
1315
1316 auto enginePriv = QQmlEnginePrivate::get(d->engine);
1317 // LoadHelper must be on the Heap as it derives from QQmlRefCount
1318 auto loadHelper = QQml::makeRefPointer<LoadHelper>(&enginePriv->typeLoader, uri);
1319
1320 auto [moduleStatus, type] = loadHelper->resolveType(typeName);
1321 auto reportError = [&](QString msg) {
1323 error.setDescription(msg);
1324 d->state.errors.push_back(std::move(error));
1326 };
1327 if (moduleStatus == LoadHelper::ResolveTypeResult::NoSuchModule) {
1328 reportError(QLatin1String(R"(No module named "%1" found)")
1329 .arg(uri.toString()));
1330 } else if (!type.isValid()) {
1331 reportError(QLatin1String(R"(Module "%1" contains no type named "%2")")
1332 .arg(uri.toString(), typeName.toString()));
1333 } else if (type.isCreatable()) {
1334 d->clear();
1335 // mimic the progressChanged behavior from loadUrl
1336 if (d->progress != 0) {
1337 d->progress = 0;
1339 }
1340 d->loadedType = type;
1341 d->progress = 1;
1344
1345 } else if (type.isComposite()) {
1346 loadUrl(type.sourceUrl(), mode);
1347 } else if (type.isInlineComponentType()) {
1348 auto baseUrl = type.sourceUrl();
1351 if (!isError()) {
1352 d->inlineComponentName = std::make_unique<QString>(type.elementName());
1353 Q_ASSERT(!d->inlineComponentName->isEmpty());
1354 }
1355 } else if (type.isSingleton() || type.isCompositeSingleton()) {
1356 reportError(QLatin1String(R"(%1 is a singleton, and cannot be loaded)")
1357 .arg(typeName.toString()));
1358 } else {
1359 reportError(QLatin1String("Could not load %1, as the type is uncreatable")
1360 .arg(typeName.toString()));
1361 }
1362}
1363
1385{
1386 Q_D(QQmlComponent);
1387
1388 if (!context)
1389 context = d->engine->rootContext();
1390
1392 QQmlRefPointer<QQmlContextData> forContextData =
1393 forContext ? QQmlContextData::get(forContext) : contextData;
1394
1395 if (!contextData->isValid()) {
1396 qWarning("QQmlComponent: Cannot create a component in an invalid context");
1397 return;
1398 }
1399
1400 if (contextData->engine() != d->engine) {
1401 qWarning("QQmlComponent: Must create component in context from the same QQmlEngine");
1402 return;
1403 }
1404
1405 if (!isReady()) {
1406 qWarning("QQmlComponent: Component is not ready");
1407 return;
1408 }
1409
1410 incubator.clear();
1412
1413 if (d->loadedType.isValid()) {
1414 // there isn't really an incubation process for C++ backed types
1415 // so just create the object and signal that we are ready
1416
1417 p->incubateCppBasedComponent(this, context);
1418 return;
1419 }
1420
1421 QQmlEnginePrivate *enginePriv = QQmlEnginePrivate::get(d->engine);
1422
1423 p->compilationUnit = d->compilationUnit;
1424 p->enginePriv = enginePriv;
1425 p->creator.reset(new QQmlObjectCreator(contextData, d->compilationUnit, d->creationContext, p.data()));
1426 p->subComponentToCreate = d->start;
1427
1428 enginePriv->incubate(incubator, forContextData);
1429}
1430
1444{
1445 Q_D(QQmlComponent);
1446 for (auto it = properties.constBegin(); it != properties.constEnd(); ++it)
1447 d->setInitialProperty(component, it.key(), it.value());
1448}
1449
1450/*
1451 This is essentially a copy of QQmlComponent::create(); except it takes the QQmlContextData
1452 arguments instead of QQmlContext which means we don't have to construct the rather weighty
1453 wrapper class for every delegate item.
1454
1455 This is used by QQmlDelegateModel.
1456*/
1458 QQmlIncubator *incubationTask,
1462 const QQmlRefPointer<QQmlContextData> &forContext)
1463{
1464 QQmlIncubatorPrivate *incubatorPriv = QQmlIncubatorPrivate::get(incubationTask);
1467
1468 incubatorPriv->compilationUnit = componentPriv->compilationUnit;
1469 incubatorPriv->enginePriv = enginePriv;
1470 incubatorPriv->creator.reset(new QQmlObjectCreator(context, componentPriv->compilationUnit, componentPriv->creationContext));
1471
1472 if (start == -1) {
1473 if (const QString *icName = componentPriv->inlineComponentName.get()) {
1475 Q_ASSERT(start > 0);
1476 }
1477 }
1478 incubatorPriv->subComponentToCreate = componentPriv->start;
1479
1480 enginePriv->incubate(*incubationTask, forContext);
1481}
1482
1483
1484
1486
1487namespace QV4 {
1488
1489namespace Heap {
1490
1491#define QmlIncubatorObjectMembers(class, Member) \
1492 Member(class, HeapValue, HeapValue, valuemap) \
1493 Member(class, HeapValue, HeapValue, statusChanged) \
1494 Member(class, Pointer, QmlContext *, qmlContext) \
1495 Member(class, NoMark, QQmlComponentIncubator *, incubator) \
1496 Member(class, NoMark, QV4QPointer<QObject>, parent)
1497
1500
1502 inline void destroy();
1503};
1504
1505}
1506
1508{
1511
1512 static ReturnedValue method_get_statusChanged(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
1513 static ReturnedValue method_set_statusChanged(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
1514 static ReturnedValue method_get_status(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
1515 static ReturnedValue method_get_object(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
1516 static ReturnedValue method_forceCompletion(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
1517
1519 void setInitialState(QObject *, RequiredProperties *requiredProperties);
1520};
1521
1522}
1523
1525
1527{
1528public:
1529 QQmlComponentIncubator(QV4::Heap::QmlIncubatorObject *inc, IncubationMode mode)
1531 {
1532 incubatorObject.set(inc->internalClass->engine, inc);
1533 }
1534
1535 void statusChanged(Status s) override {
1538 i->statusChanged(s);
1539 }
1540
1541 void setInitialState(QObject *o) override {
1544 auto d = QQmlIncubatorPrivate::get(this);
1545 i->setInitialState(o, d->requiredProperties());
1546 }
1547
1548 QV4::PersistentValue incubatorObject; // keep a strong internal reference while incubating
1549};
1550
1551
1553{
1554 if (parent) {
1555 me->setParent(parent);
1558
1559 bool needParent = false;
1560 for (int ii = 0; ii < functions.size(); ++ii) {
1561 QQmlPrivate::AutoParentResult res = functions.at(ii)(me, parent);
1562 if (res == QQmlPrivate::Parented) {
1563 needParent = false;
1564 break;
1565 } else if (res == QQmlPrivate::IncompatibleParent) {
1566 needParent = true;
1567 }
1568 }
1569 if (needParent)
1570 qmlWarning(me) << "Created graphical object was not placed in the graphics scene.";
1571 }
1572}
1573
1619 const QV4::Value &v, RequiredProperties *requiredProperties, QObject *createdComponent,
1621{
1622 QV4::Scope scope(engine);
1624 QV4::ScopedObject valueMap(scope, v);
1626 QV4::ScopedString name(scope);
1627 QV4::ScopedValue val(scope);
1628 if (engine->hasException)
1629 return;
1630
1631 // js modules (mjs) have no qmlContext
1632 QV4::ScopedStackFrame frame(scope, qmlContext ? qmlContext : engine->scriptContext());
1633
1634 while (1) {
1635 name = it.nextPropertyNameAsString(val);
1636 if (!name)
1637 break;
1638 object = o;
1639 const QStringList properties = name->toQString().split(QLatin1Char('.'));
1640 bool isTopLevelProperty = properties.size() == 1;
1641 for (int i = 0; i < properties.size() - 1; ++i) {
1642 name = engine->newString(properties.at(i));
1643 object = object->get(name);
1644 if (engine->hasException || !object) {
1645 break;
1646 }
1647 }
1648 if (engine->hasException) {
1649 qmlWarning(createdComponent, engine->catchExceptionAsQmlError());
1650 continue;
1651 }
1652 if (!object) {
1654 error.setUrl(qmlContext ? qmlContext->qmlContext()->url() : QUrl());
1655 error.setDescription(QLatin1String("Cannot resolve property \"%1\".")
1656 .arg(properties.join(u'.')));
1657 qmlWarning(createdComponent, error);
1658 continue;
1659 }
1660 const QString lastProperty = properties.last();
1661 name = engine->newString(lastProperty);
1662 object->put(name, val);
1663 if (engine->hasException) {
1664 qmlWarning(createdComponent, engine->catchExceptionAsQmlError());
1665 continue;
1666 } else if (isTopLevelProperty && requiredProperties) {
1667 auto prop = removePropertyFromRequired(createdComponent, name->toQString(),
1668 requiredProperties, engine->qmlEngine());
1669 }
1670
1671 removePendingQPropertyBinding(object, lastProperty, creator);
1672 }
1673
1674 engine->hasException = false;
1675}
1676
1678{
1680 QString description = QLatin1String("Required property %1 was not initialized").arg(unsetRequiredProperty.propertyName);
1681 switch (unsetRequiredProperty.aliasesToRequired.size()) {
1682 case 0:
1683 break;
1684 case 1: {
1685 const auto info = unsetRequiredProperty.aliasesToRequired.first();
1686 description += QLatin1String("\nIt can be set via the alias property %1 from %2\n").arg(info.propertyName, info.fileUrl.toString());
1687 break;
1688 }
1689 default:
1690 description += QLatin1String("\nIt can be set via one of the following alias properties:");
1691 for (auto aliasInfo: unsetRequiredProperty.aliasesToRequired) {
1692 description += QLatin1String("\n- %1 (%2)").arg(aliasInfo.propertyName, aliasInfo.fileUrl.toString());
1693 }
1694 description += QLatin1Char('\n');
1695 }
1696 error.setDescription(description);
1697 error.setUrl(unsetRequiredProperty.fileUrl);
1699 unsetRequiredProperty.location.line()));
1701 unsetRequiredProperty.location.column()));
1702 return error;
1703}
1704
1705#if QT_DEPRECATED_SINCE(6, 3)
1710{
1711 Q_D(QQmlComponent);
1712 Q_ASSERT(d->engine);
1713 Q_ASSERT(args);
1714
1715 qmlWarning(this) << "Unsuitable arguments passed to createObject(). The first argument should "
1716 "be a QObject* or null, and the second argument should be a JavaScript "
1717 "object or a QVariantMap";
1718
1719 QObject *parent = nullptr;
1720 QV4::ExecutionEngine *v4 = args->v4engine();
1721 QV4::Scope scope(v4);
1723
1724 if (args->length() >= 1) {
1725 QV4::Scoped<QV4::QObjectWrapper> qobjectWrapper(scope, (*args)[0]);
1726 if (qobjectWrapper)
1727 parent = qobjectWrapper->object();
1728 }
1729
1730 if (args->length() >= 2) {
1731 QV4::ScopedValue v(scope, (*args)[1]);
1732 if (!v->as<QV4::Object>() || v->as<QV4::ArrayObject>()) {
1733 qmlWarning(this) << tr("createObject: value is not an object");
1734 args->setReturnValue(QV4::Encode::null());
1735 return;
1736 }
1737 valuemap = v;
1738 }
1739
1740 QQmlContext *ctxt = creationContext();
1741 if (!ctxt) ctxt = d->engine->rootContext();
1742
1743 QObject *rv = beginCreate(ctxt);
1744
1745 if (!rv) {
1746 args->setReturnValue(QV4::Encode::null());
1747 return;
1748 }
1749
1751
1753 Q_ASSERT(object->isObject());
1754
1755 if (!valuemap->isUndefined()) {
1758 v4, qmlContext, object, valuemap, d->state.requiredProperties(), rv,
1759 d->state.creator());
1760 }
1761 if (d->state.hasUnsetRequiredProperties()) {
1763 for (const auto &requiredProperty: std::as_const(*d->state.requiredProperties())) {
1765 }
1766 qmlWarning(rv, errors);
1767 args->setReturnValue(QV4::Encode::null());
1768 delete rv;
1769 return;
1770 }
1771
1772 d->completeCreate();
1773
1776 QQmlData::get(rv)->indestructible = false;
1777
1778 args->setReturnValue(object->asReturnedValue());
1779}
1780#endif
1781
1786{
1787 Q_D(QQmlComponent);
1788 Q_ASSERT(d->engine);
1789 QObject *rv = d->createWithProperties(parent, properties, creationContext(),
1791 if (rv) {
1792 QQmlData *qmlData = QQmlData::get(rv);
1793 Q_ASSERT(qmlData);
1794 qmlData->explicitIndestructibleSet = false;
1795 qmlData->indestructible = false;
1796 }
1797 return rv;
1798}
1799
1859{
1860 Q_D(QQmlComponent);
1861 Q_ASSERT(d->engine);
1862 Q_UNUSED(d);
1863 Q_ASSERT(args);
1864 QV4::ExecutionEngine *v4 = args->v4engine();
1865 QV4::Scope scope(v4);
1866
1867 QObject *parent = nullptr;
1870
1871 if (args->length() >= 1) {
1872 QV4::Scoped<QV4::QObjectWrapper> qobjectWrapper(scope, (*args)[0]);
1873 if (qobjectWrapper)
1874 parent = qobjectWrapper->object();
1875 }
1876
1877 if (args->length() >= 2) {
1878 QV4::ScopedValue v(scope, (*args)[1]);
1879 if (v->isNull()) {
1880 } else if (!v->as<QV4::Object>() || v->as<QV4::ArrayObject>()) {
1881 qmlWarning(this) << tr("createObject: value is not an object");
1882 args->setReturnValue(QV4::Encode::null());
1883 return;
1884 } else {
1885 valuemap = v;
1886 }
1887 }
1888
1889 if (args->length() >= 3) {
1890 QV4::ScopedValue val(scope, (*args)[2]);
1891 quint32 v = val->toUInt32();
1892 if (v == 0)
1894 else if (v == 1)
1896 }
1897
1898 QQmlComponentExtension *e = componentExtension(args->v4engine());
1899
1901 QV4::ScopedObject p(scope, e->incubationProto.value());
1902 r->setPrototypeOf(p);
1903
1904 if (!valuemap->isUndefined())
1905 r->d()->valuemap.set(scope.engine, valuemap);
1906 r->d()->qmlContext.set(scope.engine, v4->qmlContext());
1907 r->d()->parent = parent;
1908
1909 QQmlIncubator *incubator = r->d()->incubator;
1910 create(*incubator, creationContext());
1911
1912 if (incubator->status() == QQmlIncubator::Null) {
1913 args->setReturnValue(QV4::Encode::null());
1914 } else {
1915 args->setReturnValue(r.asReturnedValue());
1916 }
1917}
1918
1919// XXX used by QSGLoader
1921{
1922 QV4::ExecutionEngine *v4engine = engine->handle();
1923 QV4::Scope scope(v4engine);
1924
1925 QV4::ScopedValue object(scope, QV4::QObjectWrapper::wrap(v4engine, toCreate));
1926 Q_ASSERT(object->as<QV4::Object>());
1927
1928 if (!valuemap.isUndefined()) {
1930 v4engine, qmlContext, object, valuemap, requiredProperties, toCreate, state.creator());
1931 }
1932}
1933
1935{
1936 QV4::Scope scope(v4);
1937 QV4::ScopedObject proto(scope, v4->newObject());
1938 proto->defineAccessorProperty(QStringLiteral("onStatusChanged"),
1940 proto->defineAccessorProperty(QStringLiteral("status"), QV4::QmlIncubatorObject::method_get_status, nullptr);
1941 proto->defineAccessorProperty(QStringLiteral("object"), QV4::QmlIncubatorObject::method_get_object, nullptr);
1942 proto->defineDefaultProperty(QStringLiteral("forceCompletion"), QV4::QmlIncubatorObject::method_forceCompletion);
1943
1944 incubationProto.set(v4, proto);
1945}
1946
1948{
1949 QV4::Scope scope(b);
1951 if (!o)
1953
1954 return QV4::QObjectWrapper::wrap(scope.engine, o->d()->incubator->object());
1955}
1956
1958{
1959 QV4::Scope scope(b);
1961 if (!o)
1963
1964 o->d()->incubator->forceCompletion();
1965
1967}
1968
1970{
1971 QV4::Scope scope(b);
1973 if (!o)
1975
1976 return QV4::Encode(o->d()->incubator->status());
1977}
1978
1980{
1981 QV4::Scope scope(b);
1983 if (!o)
1985
1986 return QV4::Encode(o->d()->statusChanged);
1987}
1988
1990{
1991 QV4::Scope scope(b);
1993 if (!o || argc < 1)
1995
1996 o->d()->statusChanged.set(scope.engine, argv[0]);
1997
1999}
2000
2002{
2003}
2004
2005void QV4::Heap::QmlIncubatorObject::init(QQmlIncubator::IncubationMode m)
2006{
2007 Object::init();
2008 valuemap.set(internalClass->engine, QV4::Value::undefinedValue());
2009 statusChanged.set(internalClass->engine, QV4::Value::undefinedValue());
2010 parent.init();
2011 qmlContext.set(internalClass->engine, nullptr);
2012 incubator = new QQmlComponentIncubator(this, m);
2013}
2014
2015void QV4::Heap::QmlIncubatorObject::destroy() {
2016 delete incubator;
2017 parent.destroy();
2018 Object::destroy();
2019}
2020
2022{
2024
2025 if (!d()->valuemap.isUndefined()) {
2027 QV4::Scope scope(v4);
2029 QV4::Scoped<QV4::QmlContext> qmlCtxt(scope, d()->qmlContext);
2031 v4, qmlCtxt, obj, d()->valuemap, requiredProperties, o,
2032 QQmlIncubatorPrivate::get(d()->incubator)->creator.data());
2033 }
2034}
2035
2037{
2038 QV4::Scope scope(engine());
2039 // hold the incubated object in a scoped value to prevent it's destruction before this method returns
2040 QV4::ScopedObject incubatedObject(scope, QV4::QObjectWrapper::wrap(scope.engine, d()->incubator->object()));
2041
2042 if (s == QQmlIncubator::Ready) {
2043 Q_ASSERT(QQmlData::get(d()->incubator->object()));
2044 QQmlData::get(d()->incubator->object())->explicitIndestructibleSet = false;
2045 QQmlData::get(d()->incubator->object())->indestructible = false;
2046 }
2047
2049 if (f) {
2050 QV4::JSCallArguments jsCallData(scope, 1);
2051 *jsCallData.thisObject = this;
2052 jsCallData.args[0] = QV4::Value::fromUInt32(s);
2053 f->call(jsCallData);
2054 if (scope.hasException()) {
2057 }
2058 }
2059
2061 d()->incubator->incubatorObject.clear();
2062}
2063
2064#undef INITIALPROPERTIES_SOURCE
2065
2067
2068#include "moc_qqmlcomponent.cpp"
2069#include "moc_qqmlcomponentattached_p.cpp"
\inmodule QtCore
QString toString() const
Returns a deep copy of this string view's data as a QString.
Definition qstring.h:1071
\inmodule QtCore
Definition qbytearray.h:57
static bool isAbsolutePath(const QString &path)
Returns true if path is absolute; returns false if it is relative.
Definition qdir.h:183
iterator find(const Key &key)
Returns an iterator pointing to the item with the key in the hash.
Definition qhash.h:1258
iterator erase(const_iterator it)
Definition qhash.h:1223
iterator end() noexcept
Returns an \l{STL-style iterators}{STL-style iterator} pointing to the imaginary item after the last ...
Definition qhash.h:1206
QV4::ExecutionEngine * handle() const
Definition qjsengine.h:292
QString arg(Args &&...args) const
Definition qlist.h:74
qsizetype size() const noexcept
Definition qlist.h:386
void push_back(parameter_type t)
Definition qlist.h:672
qsizetype length() const noexcept
Definition qlist.h:388
const_reference at(qsizetype i) const noexcept
Definition qlist.h:429
reference emplaceBack(Args &&... args)
Definition qlist.h:875
void reserve(qsizetype size)
Definition qlist.h:746
bool isBindable() const
QObject * parent
Definition qobject.h:61
\inmodule QtCore
Definition qobject.h:90
QObject * parent() const
Returns a pointer to the parent object.
Definition qobject.h:311
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
Definition qobject.cpp:2823
void setParent(QObject *parent)
Makes the object a child of parent.
Definition qobject.cpp:2142
void destroyed(QObject *=nullptr)
This signal is emitted immediately before the object obj is destroyed, after any instances of QPointe...
QQmlComponentAttached(QObject *parent=nullptr)
QV4::PersistentValue incubationProto
QQmlComponentExtension(QV4::ExecutionEngine *v4)
void setInitialState(QObject *o) override
Called after the object is first created, but before 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
static void complete(QQmlEnginePrivate *enginePriv, ConstructionState *state)
ConstructionState state
virtual void incubateObject(QQmlIncubator *incubationTask, QQmlComponent *component, QQmlEngine *engine, const QQmlRefPointer< QQmlContextData > &context, const QQmlRefPointer< QQmlContextData > &forContext)
QQmlRefPointer< QV4::ExecutableCompilationUnit > compilationUnit
QObject * beginCreate(QQmlRefPointer< QQmlContextData >)
std::vector< ConstructionState > DeferredState
static QQmlError unsetRequiredPropertyToQQmlError(const RequiredPropertyInfo &unsetRequiredProperty)
std::unique_ptr< QString > inlineComponentName
bool hadTopLevelRequiredProperties() const
bool setInitialProperty(QObject *component, const QString &name, const QVariant &value)
void typeDataProgress(QQmlTypeData *, qreal) override
QObject * doBeginCreate(QQmlComponent *q, QQmlContext *context)
static QQmlComponentPrivate * get(QQmlComponent *c)
QObject * createWithProperties(QObject *parent, const QVariantMap &properties, QQmlContext *context, CreateBehavior behavior=CreateDefault)
void typeDataReady(QQmlTypeData *) override
static void completeDeferred(QQmlEnginePrivate *enginePriv, DeferredState *deferredState)
static void beginDeferred(QQmlEnginePrivate *enginePriv, QObject *object, DeferredState *deferredState)
void loadUrl(const QUrl &newUrl, QQmlComponent::CompilationMode mode=QQmlComponent::PreferSynchronous)
QQmlGuardedContextData creationContext
void fromTypeData(const QQmlRefPointer< QQmlTypeData > &data)
static void setInitialProperties(QV4::ExecutionEngine *engine, QV4::QmlContext *qmlContext, const QV4::Value &o, const QV4::Value &v, RequiredProperties *requiredProperties, QObject *createdComponent, QQmlObjectCreator *creator)
\qmlmethod QtObject Component::createObject(QtObject parent, object properties)
void initializeObjectWithInitialProperties(QV4::QmlContext *qmlContext, const QV4::Value &valuemap, QObject *toCreate, RequiredProperties *requiredProperties)
QQmlRefPointer< QQmlTypeData > typeData
static QQmlProperty removePropertyFromRequired(QObject *createdComponent, const QString &name, RequiredProperties *requiredProperties, QQmlEngine *engine, bool *wasInRequiredProperties=nullptr)
The QQmlComponent class encapsulates a QML component definition.
bool isError() const
Returns true if status() == QQmlComponent::Error.
friend class QQmlObjectCreator
bool isBound() const
Returns true if the component was created in a QML files that specifies {pragma ComponentBehavior: Bo...
bool isNull() const
Returns true if status() == QQmlComponent::Null.
virtual QObject * beginCreate(QQmlContext *)
Create an object instance from this component, within the specified context.
bool isLoading() const
Returns true if status() == QQmlComponent::Loading.
static QQmlComponentAttached * qmlAttachedProperties(QObject *)
virtual void completeCreate()
This method provides advanced control over component instance creation.
void loadFromModule(QAnyStringView uri, QAnyStringView typeName, QQmlComponent::CompilationMode mode=PreferSynchronous)
Load the QQmlComponent for typeName in the module uri.
QQmlContext * creationContext() const
Returns the QQmlContext the component was created in.
void setInitialProperties(QObject *component, const QVariantMap &properties)
Set top-level properties of the component.
Status status
\qmlproperty enumeration Component::status
QList< QQmlError > errors() const
Returns the list of errors that occurred during the last compile or create operation.
Q_INVOKABLE void incubateObject(QQmlV4Function *)
\qmlmethod object Component::incubateObject(QtObject parent, object properties, enumeration mode)
Q_INVOKABLE QObject * createObject(QObject *parent=nullptr, const QVariantMap &properties={})
QUrl url
\qmlproperty url Component::url The component URL.
CompilationMode
Specifies whether the QQmlComponent should load the component immediately, or asynchonously.
qreal progress
\qmlproperty real Component::progress The progress of loading the component, from 0....
~QQmlComponent() override
Destruct the QQmlComponent.
bool isReady() const
Returns true if status() == QQmlComponent::Ready.
void setData(const QByteArray &, const QUrl &baseUrl)
Sets the QQmlComponent to use the given QML data.
void loadUrl(const QUrl &url)
Load the QQmlComponent from the provided url.
void progressChanged(qreal)
Emitted whenever the component's loading progress changes.
QQmlComponent(QObject *parent=nullptr)
QQmlEngine * engine() const
Returns the QQmlEngine of this component.
Q_INVOKABLE QString errorString() const
\qmlmethod string Component::errorString()
virtual QObject * create(QQmlContext *context=nullptr)
Create an object instance from this component, within the specified context.
QObject * createWithInitialProperties(const QVariantMap &initialProperties, QQmlContext *context=nullptr)
Create an object instance of this component, within the specified context, and initialize its top-lev...
void statusChanged(QQmlComponent::Status)
Emitted whenever the component's status changes.
static QQmlRefPointer< QQmlContextData > get(QQmlContext *context)
The QQmlContext class defines a context within a QML engine.
Definition qqmlcontext.h:25
static QQmlPropertyCache::ConstPtr ensurePropertyCache(QObject *object)
Definition qqmldata_p.h:252
QVector< DeferredData * > deferredData
Definition qqmldata_p.h:187
quint32 explicitIndestructibleSet
Definition qqmldata_p.h:95
static QQmlData * get(QObjectPrivate *priv, bool create)
Definition qqmldata_p.h:199
quint32 rootObjectInCreation
Definition qqmldata_p.h:104
quint32 indestructible
Definition qqmldata_p.h:92
Q_REQUIRED_RESULT QQmlError removeError()
void warning(const QQmlError &)
QQmlTypeLoader typeLoader
void incubate(QQmlIncubator &, const QQmlRefPointer< QQmlContextData > &)
static QQmlEnginePrivate * get(QQmlEngine *e)
void referenceScarceResources()
QQmlDelayedError * erroredBindings
void dereferenceScarceResources()
The QQmlEngine class provides an environment for instantiating QML components.
Definition qqmlengine.h:57
QQmlContext * rootContext() const
Returns the engine's root context.
QUrl baseUrl() const
Return the base URL for this engine.
QQmlEngine * qmlEngine(const QObject *object)
Returns the QQmlEngine associated with object, if any.
Definition qqml.cpp:76
The QQmlError class encapsulates a QML error.
Definition qqmlerror.h:18
static QQmlIncubatorPrivate * get(QQmlIncubator *incubator)
QScopedPointer< QQmlObjectCreator > creator
QQmlRefPointer< QV4::ExecutableCompilationUnit > compilationUnit
QQmlEnginePrivate * enginePriv
The QQmlIncubator class allows QML objects to be created asynchronously.
void clear()
Clears the incubator.
IncubationMode
Specifies the mode the incubator operates in.
Status status() const
Return the current status of the incubator.
Status
Specifies the status of the QQmlIncubator.
static QString prettyTypeName(const QObject *object)
Returns the pretty QML type name (e.g.
static QList< QQmlPrivate::AutoParentFunction > parentFunctions()
bool finalize(QQmlInstantiationInterrupt &interrupt)
bool componentHadTopLevelRequiredProperties() const
QObject * create(int subComponentIndex=-1, QObject *parent=nullptr, QQmlInstantiationInterrupt *interrupt=nullptr, int flags=NormalObject)
static void findAliasTarget(QObject *, QQmlPropertyIndex, QObject **, QQmlPropertyIndex *)
static QQmlPropertyPrivate * get(const QQmlProperty &p)
bool writeValueProperty(const QVariant &, QQmlPropertyData::WriteFlags)
The QQmlProperty class abstracts accessing properties on objects created from QML.
bool isBindable() const
bool isValid() const
Returns true if the QQmlProperty refers to a valid property, otherwise false.
int index() const
Return the Qt metaobject index of the property.
QML_ANONYMOUSQObject * object
void reset(T *t=nullptr)
void registerCallback(TypeDataCallback *)
void unregisterCallback(TypeDataCallback *)
QQmlRefPointer< QQmlTypeData > getType(const QUrl &unNormalizedUrl, Mode mode=PreferSynchronous)
Returns a QQmlTypeData for the specified url.
QObject * createWithQQmlData() const
Definition qqmltype.cpp:498
bool isValid() const
Definition qqmltype_p.h:58
void reset(T *other=nullptr) noexcept(noexcept(Cleanup::cleanup(std::declval< T * >())))
Deletes the existing object it is pointing to (if any), and sets its pointer to other.
\inmodule QtCore
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:127
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qstring.cpp:7822
QByteArray toUtf8() const &
Definition qstring.h:563
\inmodule QtCore
Definition qurl.h:94
static QUrl fromLocalFile(const QString &localfile)
Returns a QUrl representation of localFile, interpreted as a local file.
Definition qurl.cpp:3354
bool isLocalFile() const
Definition qurl.cpp:3431
QUrl resolved(const QUrl &relative) const
Returns the result of the merge of this URL with relative.
Definition qurl.cpp:2722
void setFragment(const QString &fragment, ParsingMode mode=TolerantMode)
Sets the fragment of the URL to fragment.
Definition qurl.cpp:2645
bool isRelative() const
Returns true if the URL is relative; otherwise returns false.
Definition qurl.cpp:2797
bool isEmpty() const
Returns true if the URL has no data; otherwise returns false.
Definition qurl.cpp:1888
void setScheme(const QString &scheme)
Sets the scheme of the URL to scheme.
Definition qurl.cpp:1959
QString toString(FormattingOptions options=FormattingOptions(PrettyDecoded)) const
Returns a string representation of the URL.
Definition qurl.cpp:2828
QString toLocalFile() const
Returns the path of this URL formatted as a local file path.
Definition qurl.cpp:3411
int inlineComponentId(const QString &inlineComponentName) const
ObjectType::Data * allocate(Args &&... args)
Definition qv4mm_p.h:199
ExecutionEngine * engine() const
void set(ExecutionEngine *engine, const Value &value)
\inmodule QtCore
Definition qvariant.h:64
void statusChanged(QDeclarativeComponent::Status status)
[1]
Definition qlogging.cpp:9
double e
QSet< QString >::iterator it
else opt state
[0]
AutoParentResult(* AutoParentFunction)(QObject *object, QObject *parent)
Combined button and popup list for selecting options.
\qmltype Particle \inqmlmodule QtQuick.Particles
quint64 ReturnedValue
static void * context
static const QCssKnownValue properties[NumProperties - 1]
DBusConnection const char DBusError * error
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
#define qWarning
Definition qlogging.h:162
#define Q_LOGGING_CATEGORY(name,...)
#define qCDebug(category,...)
return ret
const char * typeName
GLboolean GLboolean GLboolean b
GLsizei const GLfloat * v
[13]
GLenum mode
const GLfloat * m
GLboolean GLboolean GLboolean GLboolean a
[7]
GLuint index
[2]
GLboolean r
[2]
GLuint object
[3]
GLfloat GLfloat f
GLenum type
GLenum target
GLbitfield flags
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLuint start
GLuint name
GLhandleARB obj
[2]
GLuint res
GLuint GLfloat * val
GLuint segment
GLdouble GLdouble GLdouble GLdouble q
Definition qopenglext.h:259
GLdouble s
[6]
Definition qopenglext.h:235
GLfloat GLfloat p
[1]
static qreal component(const QPointF &point, unsigned int i)
QQmlEngine * qmlEngine(const QObject *obj)
Definition qqml.cpp:76
QQmlContext * qmlContext(const QObject *obj)
Definition qqml.cpp:71
static void removePendingQPropertyBinding(QV4::Value *object, const QString &propertyName, QQmlObjectCreator *creator)
static void QQmlComponent_setQmlParent(QObject *me, QObject *parent)
Q_QML_EXPORT QQmlInfo qmlWarning(const QObject *me)
int qmlConvertSourceCoordinate< quint32, int >(quint32 n)
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
QScopeGuard< typename std::decay< F >::type > qScopeGuard(F &&f)
[qScopeGuard]
Definition qscopeguard.h:60
SSL_CTX int(*) void arg)
QLatin1StringView QLatin1String
Definition qstringfwd.h:31
#define QStringLiteral(str)
#define tr(X)
static QT_BEGIN_NAMESPACE void init(QTextBoundaryFinder::BoundaryType type, QStringView str, QCharAttributes *attributes)
#define emit
#define Q_UNUSED(x)
unsigned int quint32
Definition qtypes.h:45
double qreal
Definition qtypes.h:92
#define V4_DEFINE_EXTENSION(dataclass, datafunction)
Definition qv4engine_p.h:38
#define V4_NEEDS_DESTROY
#define DECLARE_HEAP_OBJECT(name, base)
#define DECLARE_MARKOBJECTS(class)
#define THROW_TYPE_ERROR()
#define RETURN_UNDEFINED()
#define DEFINE_OBJECT_VTABLE(classname)
#define V4_OBJECT2(DataClass, superClass)
QFileInfo info(fileName)
[8]
QUrl url("example.com")
[constructor-url-reference]
QUrl baseUrl
QObject::connect nullptr
QItemEditorCreatorBase * creator
QFrame frame
[0]
view create()
QJSValueList args
QJSEngine engine
[0]
\inmodule QtCore \reentrant
Definition qchar.h:17
\inmodule QtCore
QMetaProperty property(int index) const
Returns the meta-data for the property with the given index.
int indexOfProperty(const char *name) const
Finds property name and returns its index; otherwise returns -1.
void appendErrors(const QList< QQmlError > &qmlErrors)
void addPendingRequiredProperty(const QObject *object, const QQmlPropertyData *propData, const RequiredPropertyInfo &info)
QQmlObjectCreator * initCreator(QQmlRefPointer< QQmlContextData > parentContext, const QQmlRefPointer< QV4::ExecutableCompilationUnit > &compilationUnit, const QQmlRefPointer< QQmlContextData > &creationContext)
static constexpr ReturnedValue null()
MemoryManager * memoryManager
Heap::String * newString(const QString &s=QString())
QQmlError catchExceptionAsQmlError()
Heap::Object * newObject()
QV4::ReturnedValue metaTypeToJS(QMetaType type, const void *data)
QQmlEngine * qmlEngine() const
static Heap::ExecutionContext * qmlContext(Heap::ExecutionContext *ctx)
static ReturnedValue wrap(ExecutionEngine *engine, QObject *object)
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 V4_NEEDS_DESTROY ReturnedValue method_get_statusChanged(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)
bool hasException() const
ExecutionEngine * engine
bool isUndefined() const
static constexpr Value undefinedValue()
Definition qv4value_p.h:191
const T * as() const
Definition qv4value_p.h:132
static Value fromUInt32(uint i)
Definition qv4value_p.h:203
QVector< AliasToRequiredInfo > aliasesToRequired
QV4::CompiledData::Location location
void wrapper()
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent