diff options
author | Tarja Sundqvist <tarja.sundqvist@qt.io> | 2022-04-07 15:22:02 +0300 |
---|---|---|
committer | Tarja Sundqvist <tarja.sundqvist@qt.io> | 2022-04-07 15:22:02 +0300 |
commit | 04ea6df18a2b06efd133a4f1b13c2e38817279ae (patch) | |
tree | 73b84355c755c6e21f3f66816aeb13e6a16012cd /src/qml | |
parent | 4bb06cfba94bcc9ddf30d968a227d00479d475b7 (diff) | |
parent | 1089f8f226d546aef3b032a2f4391e08a3afa48d (diff) | |
download | qtdeclarative-04ea6df18a2b06efd133a4f1b13c2e38817279ae.tar.gz |
Merge remote-tracking branch 'origin/tqtc/lts-5.15.4' into tqtc/lts-5.15-opensourcev5.15.4-lts-lgpl
Change-Id: I39595f8b7ad212c842709b939226d95531819391
Diffstat (limited to 'src/qml')
-rw-r--r-- | src/qml/jsapi/qjsvalue.h | 1 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4arrayobject.cpp | 2 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4generatorobject.cpp | 21 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4generatorobject_p.h | 3 | ||||
-rw-r--r-- | src/qml/qml/qqmlapplicationengine.cpp | 8 | ||||
-rw-r--r-- | src/qml/qml/qqmlimport.cpp | 14 | ||||
-rw-r--r-- | src/qml/qml/qqmlincubator.cpp | 2 | ||||
-rw-r--r-- | src/qml/qml/qqmllocale.cpp | 2 | ||||
-rw-r--r-- | src/qml/qml/qqmlmetatype.cpp | 12 | ||||
-rw-r--r-- | src/qml/qml/qqmlobjectcreator.cpp | 3 | ||||
-rw-r--r-- | src/qml/qml/qqmlproperty.cpp | 4 |
11 files changed, 49 insertions, 23 deletions
diff --git a/src/qml/jsapi/qjsvalue.h b/src/qml/jsapi/qjsvalue.h index 2f95e0ff31..80641ff235 100644 --- a/src/qml/jsapi/qjsvalue.h +++ b/src/qml/jsapi/qjsvalue.h @@ -57,7 +57,6 @@ class QDateTime; typedef QList<QJSValue> QJSValueList; namespace QV4 { struct ExecutionEngine; - struct Value; } class Q_QML_EXPORT QJSValue diff --git a/src/qml/jsruntime/qv4arrayobject.cpp b/src/qml/jsruntime/qv4arrayobject.cpp index df9f117d04..03e5c29973 100644 --- a/src/qml/jsruntime/qv4arrayobject.cpp +++ b/src/qml/jsruntime/qv4arrayobject.cpp @@ -254,6 +254,7 @@ ReturnedValue ArrayPrototype::method_from(const FunctionObject *builtin, const V } if (mapfn) { + Q_ASSERT(mapArguments); // if mapfn is set, we always setup mapArguments with scope.alloc mapArguments[0] = *nextValue; mapArguments[1] = Value::fromDouble(k); mappedValue = mapfn->call(thisArg, mapArguments, 2); @@ -297,6 +298,7 @@ ReturnedValue ArrayPrototype::method_from(const FunctionObject *builtin, const V CHECK_EXCEPTION(); if (mapfn) { + Q_ASSERT(mapArguments); // if mapfn is set, we always setup mapArguments with scope.alloc mapArguments[0] = kValue; mapArguments[1] = Value::fromDouble(k); mappedValue = mapfn->call(thisArg, mapArguments, 2); diff --git a/src/qml/jsruntime/qv4generatorobject.cpp b/src/qml/jsruntime/qv4generatorobject.cpp index 4eee6f4338..5077bf1d2b 100644 --- a/src/qml/jsruntime/qv4generatorobject.cpp +++ b/src/qml/jsruntime/qv4generatorobject.cpp @@ -97,24 +97,21 @@ ReturnedValue GeneratorFunction::virtualCall(const FunctionObject *f, const Valu Function *function = gf->function(); ExecutionEngine *engine = gf->engine(); - // We need to set up a separate stack for the generator, as it's being re-entered - uint stackSize = argc // space for the original arguments - + CppStackFrame::requiredJSStackFrameSize(function); // space for the JS stack frame - - size_t requiredMemory = sizeof(GeneratorObject::Data) - sizeof(Value) + sizeof(Value) * stackSize; - Scope scope(gf); - Scoped<GeneratorObject> g(scope, scope.engine->memoryManager->allocManaged<GeneratorObject>(requiredMemory, scope.engine->classes[EngineBase::Class_GeneratorObject])); + Scoped<GeneratorObject> g(scope, engine->memoryManager->allocManaged<GeneratorObject>(sizeof(GeneratorObject::Data), engine->classes[EngineBase::Class_GeneratorObject])); g->setPrototypeOf(ScopedObject(scope, gf->get(scope.engine->id_prototype()))); + // We need to set up a separate JSFrame for the generator, as it's being re-entered Heap::GeneratorObject *gp = g->d(); - gp->stack.size = stackSize; - gp->stack.alloc = stackSize; + gp->values.set(engine, engine->newArrayObject(argc)); + gp->jsFrame.set(engine, engine->newArrayObject(CppStackFrame::requiredJSStackFrameSize(function))); // copy original arguments - memcpy(gp->stack.values, argv, argc*sizeof(Value)); - gp->cppFrame.init(engine, function, gp->stack.values, argc); - gp->cppFrame.setupJSFrame(&gp->stack.values[argc], *gf, gf->scope(), + for (int i = 0; i < argc; i++) + gp->values->arrayData->setArrayData(engine, i, argv[i]); + + gp->cppFrame.init(engine, function, gp->values->arrayData->values.values, argc); + gp->cppFrame.setupJSFrame(gp->jsFrame->arrayData->values.values, *gf, gf->scope(), thisObject ? *thisObject : Value::undefinedValue(), Value::undefinedValue()); diff --git a/src/qml/jsruntime/qv4generatorobject_p.h b/src/qml/jsruntime/qv4generatorobject_p.h index 366319723d..10eea5e46b 100644 --- a/src/qml/jsruntime/qv4generatorobject_p.h +++ b/src/qml/jsruntime/qv4generatorobject_p.h @@ -90,7 +90,8 @@ struct GeneratorPrototype : FunctionObject { Member(class, Pointer, GeneratorFunction *, function) \ Member(class, NoMark, GeneratorState, state) \ Member(class, NoMark, CppStackFrame, cppFrame) \ - Member(class, ValueArray, ValueArray, stack) + Member(class, Pointer, ArrayObject *, values) \ + Member(class, Pointer, ArrayObject *, jsFrame) DECLARE_HEAP_OBJECT(GeneratorObject, Object) { DECLARE_MARKOBJECTS(GeneratorObject); diff --git a/src/qml/qml/qqmlapplicationengine.cpp b/src/qml/qml/qqmlapplicationengine.cpp index 907825d28c..2b294ffff6 100644 --- a/src/qml/qml/qqmlapplicationengine.cpp +++ b/src/qml/qml/qqmlapplicationengine.cpp @@ -146,6 +146,14 @@ void QQmlApplicationEnginePrivate::finishLoad(QQmlComponent *c) break; case QQmlComponent::Ready: { auto newObj = initialProperties.empty() ? c->create() : c->createWithInitialProperties(initialProperties); + + if (c->isError()) { + qWarning() << "QQmlApplicationEngine failed to create component"; + warning(c->errors()); + q->objectCreated(nullptr, c->url()); + break; + } + objects << newObj; QObject::connect(newObj, &QObject::destroyed, q, [&](QObject *obj) { objects.removeAll(obj); }); q->objectCreated(objects.constLast(), c->url()); diff --git a/src/qml/qml/qqmlimport.cpp b/src/qml/qml/qqmlimport.cpp index 6d4fba0aa4..10c6c41338 100644 --- a/src/qml/qml/qqmlimport.cpp +++ b/src/qml/qml/qqmlimport.cpp @@ -730,7 +730,8 @@ bool QQmlImportInstance::resolveType(QQmlTypeLoader *typeLoader, const QHashedSt if (containingType.isValid()) { // we currently cannot reference a Singleton inside itself // in that case, containingType is still invalid - if (int icID = containingType.lookupInlineComponentIdByName(typeStr) != -1) { + int icID = containingType.lookupInlineComponentIdByName(typeStr); + if (icID != -1) { *type_return = containingType.lookupInlineComponentById(icID); } else { auto icType = createICType(); @@ -1408,11 +1409,16 @@ QQmlImports::LocalQmldirResult QQmlImportsPrivate::locateLocalQmldir( if (!absoluteFilePath.isEmpty()) { QString url; const QStringRef absolutePath = absoluteFilePath.leftRef(absoluteFilePath.lastIndexOf(Slash) + 1); - if (absolutePath.at(0) == Colon) + if (absolutePath.at(0) == Colon) { url = QLatin1String("qrc") + absolutePath; - else + } else { url = QUrl::fromLocalFile(absolutePath.toString()).toString(); - + // This handles the UNC path case as when the path is retrieved from the QUrl it + // will convert the host name from upper case to lower case. So the absoluteFilePath + // is changed at this point to make sure it will match later on in that case. + if (absoluteFilePath.startsWith(QLatin1String("//"))) + absoluteFilePath = QUrl::fromLocalFile(absoluteFilePath).toString(QUrl::RemoveScheme); + } QQmlImportDatabase::QmldirCache *cache = new QQmlImportDatabase::QmldirCache; cache->versionMajor = vmaj; cache->versionMinor = vmin; diff --git a/src/qml/qml/qqmlincubator.cpp b/src/qml/qml/qqmlincubator.cpp index 0ad013e90b..244f9ad292 100644 --- a/src/qml/qml/qqmlincubator.cpp +++ b/src/qml/qml/qqmlincubator.cpp @@ -330,7 +330,7 @@ void QQmlIncubatorPrivate::incubate(QQmlInstantiationInterrupt &i) ddata->rootObjectInCreation = false; if (q) { q->setInitialState(result); - if (!creator->requiredProperties().empty()) { + if (creator && !creator->requiredProperties().empty()) { const auto& unsetRequiredProperties = creator->requiredProperties(); for (const auto& unsetRequiredProperty: unsetRequiredProperties) errors << QQmlComponentPrivate::unsetRequiredPropertyToQQmlError(unsetRequiredProperty); diff --git a/src/qml/qml/qqmllocale.cpp b/src/qml/qml/qqmllocale.cpp index 7af6af276a..f55bbe7ffc 100644 --- a/src/qml/qml/qqmllocale.cpp +++ b/src/qml/qml/qqmllocale.cpp @@ -891,7 +891,7 @@ ReturnedValue QQmlLocale::method_localeCompare(const QV4::FunctionObject *b, con */ /*! - \qmlproperty enumeration QtQml::Locale::NumberOption + \qmlproperty enumeration QtQml::Locale::numberOptions Holds a set of options for number-to-string and string-to-number conversions. diff --git a/src/qml/qml/qqmlmetatype.cpp b/src/qml/qml/qqmlmetatype.cpp index be4a79297c..40300b1fe3 100644 --- a/src/qml/qml/qqmlmetatype.cpp +++ b/src/qml/qml/qqmlmetatype.cpp @@ -1260,6 +1260,16 @@ void QQmlMetaType::unregisterType(int typeIndex) } } +static bool hasActiveInlineComponents(const QQmlTypePrivate *d) +{ + for (const QQmlType &ic : qAsConst(d->objectIdToICType)) { + const QQmlTypePrivate *icPriv = ic.priv(); + if (icPriv && icPriv->count() > 1) + return true; + } + return false; +} + void QQmlMetaType::freeUnusedTypesAndCaches() { QQmlMetaTypeDataPtr data; @@ -1274,7 +1284,7 @@ void QQmlMetaType::freeUnusedTypesAndCaches() QList<QQmlType>::Iterator it = data->types.begin(); while (it != data->types.end()) { const QQmlTypePrivate *d = (*it).priv(); - if (d && d->count() == 1) { + if (d && d->count() == 1 && !hasActiveInlineComponents(d)) { deletedAtLeastOneType = true; removeQQmlTypePrivate(data->idToType, d); diff --git a/src/qml/qml/qqmlobjectcreator.cpp b/src/qml/qml/qqmlobjectcreator.cpp index 1c8f2b2091..6aeb567a86 100644 --- a/src/qml/qml/qqmlobjectcreator.cpp +++ b/src/qml/qml/qqmlobjectcreator.cpp @@ -679,8 +679,7 @@ void QQmlObjectCreator::setPropertyValue(const QQmlPropertyData *property, const // otherwise, try a custom type assignment QString stringValue = compilationUnit->bindingValueAsString(binding); QQmlMetaType::StringConverter converter = QQmlMetaType::customStringConverter(property->propType()); - Q_ASSERT(converter); - QVariant value = (*converter)(stringValue); + QVariant value = converter ? (*converter)(stringValue) : QVariant(); QMetaProperty metaProperty = _qobject->metaObject()->property(property->coreIndex()); if (value.isNull() || metaProperty.userType() != property->propType()) { diff --git a/src/qml/qml/qqmlproperty.cpp b/src/qml/qml/qqmlproperty.cpp index 8521de6ab3..9eb81e566e 100644 --- a/src/qml/qml/qqmlproperty.cpp +++ b/src/qml/qml/qqmlproperty.cpp @@ -918,6 +918,8 @@ QQmlPropertyPrivate::signalExpression(const QQmlProperty &that) if (!(that.type() & QQmlProperty::SignalProperty)) return nullptr; + if (!that.d->object) + return nullptr; QQmlData *data = QQmlData::get(that.d->object); if (!data) return nullptr; @@ -957,6 +959,8 @@ void QQmlPropertyPrivate::takeSignalExpression(const QQmlProperty &that, return; } + if (!that.d->object) + return; QQmlData *data = QQmlData::get(that.d->object, nullptr != expr); if (!data) return; |