diff options
Diffstat (limited to 'src/qml')
-rw-r--r-- | src/qml/debugger/qqmlprofilerdefinitions_p.h | 27 | ||||
-rw-r--r-- | src/qml/jsapi/qjsvalue.cpp | 8 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4global_p.h | 2 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4qobjectwrapper.cpp | 10 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4stringobject.cpp | 4 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4vme_moth.cpp | 74 | ||||
-rw-r--r-- | src/qml/qml/qqmlcontext.cpp | 13 | ||||
-rw-r--r-- | src/qml/qml/qqmlcontext_p.h | 5 | ||||
-rw-r--r-- | src/qml/qml/qqmlengine.cpp | 2 | ||||
-rw-r--r-- | src/qml/qml/qqmlmetatype.cpp | 11 | ||||
-rw-r--r-- | src/qml/qml/qqmlmetatype_p.h | 2 | ||||
-rw-r--r-- | src/qml/qml/qqmlobjectcreator.cpp | 4 | ||||
-rw-r--r-- | src/qml/qml/qqmltypeloader.cpp | 28 | ||||
-rw-r--r-- | src/qml/qml/qqmltypeloader_p.h | 6 | ||||
-rw-r--r-- | src/qml/types/qqmldelegatemodel.cpp | 7 |
15 files changed, 101 insertions, 102 deletions
diff --git a/src/qml/debugger/qqmlprofilerdefinitions_p.h b/src/qml/debugger/qqmlprofilerdefinitions_p.h index f84a2c44e2..7b972c5d0d 100644 --- a/src/qml/debugger/qqmlprofilerdefinitions_p.h +++ b/src/qml/debugger/qqmlprofilerdefinitions_p.h @@ -96,11 +96,6 @@ struct QQmlProfilerDefinitions { MaximumRangeType }; - enum BindingType { - QmlBinding, - MaximumBindingType - }; - enum PixmapEventType { PixmapSizeKnown, PixmapReferenceCountChanged, @@ -129,8 +124,6 @@ struct QQmlProfilerDefinitions { NumGUIThreadFrameTypes = MaximumSceneGraphFrameType - NumRenderThreadFrameTypes }; - typedef QV4::Profiling::MemoryType MemoryType; - enum ProfileFeature { ProfileJavaScript, ProfileMemory, @@ -162,26 +155,6 @@ struct QQmlProfilerDefinitions { MaximumInputEventType }; - - static ProfileFeature featureFromRangeType(RangeType range) - { - switch (range) { - case Painting: - return ProfilePainting; - case Compiling: - return ProfileCompiling; - case Creating: - return ProfileCreating; - case Binding: - return ProfileBinding; - case HandlingSignal: - return ProfileHandlingSignal; - case Javascript: - return ProfileJavaScript; - default: - return MaximumProfileFeature; - } - } }; QT_END_NAMESPACE diff --git a/src/qml/jsapi/qjsvalue.cpp b/src/qml/jsapi/qjsvalue.cpp index b97468ab7b..348ddb25d9 100644 --- a/src/qml/jsapi/qjsvalue.cpp +++ b/src/qml/jsapi/qjsvalue.cpp @@ -409,7 +409,7 @@ bool QJSValue::isObject() const QV4::Value *val = QJSValuePrivate::getValue(this); if (!val) return false; - return val->as<Object>(); + return val->as<QV4::Object>(); } /*! @@ -649,7 +649,7 @@ QVariant QJSValue::toVariant() const QV4::Value *val = QJSValuePrivate::valueForData(this, &scratch); Q_ASSERT(val); - if (Object *o = val->as<Object>()) + if (QV4::Object *o = val->as<QV4::Object>()) return o->engine()->toVariant(*val, /*typeHint*/ -1, /*createJSValueForObjects*/ false); if (String *s = val->stringValue()) @@ -849,7 +849,7 @@ QJSValue QJSValue::prototype() const if (!engine) return QJSValue(); QV4::Scope scope(engine); - ScopedObject o(scope, QJSValuePrivate::getValue(this)->as<Object>()); + ScopedObject o(scope, QJSValuePrivate::getValue(this)->as<QV4::Object>()); if (!o) return QJSValue(); ScopedObject p(scope, o->prototype()); @@ -931,7 +931,7 @@ static bool js_equal(const QString &string, const QV4::Value &value) return RuntimeHelpers::stringToNumber(string) == value.asDouble(); if (value.isBoolean()) return RuntimeHelpers::stringToNumber(string) == double(value.booleanValue()); - if (Object *o = value.objectValue()) { + if (QV4::Object *o = value.objectValue()) { Scope scope(o->engine()); ScopedValue p(scope, RuntimeHelpers::toPrimitive(value, PREFERREDTYPE_HINT)); return js_equal(string, p); diff --git a/src/qml/jsruntime/qv4global_p.h b/src/qml/jsruntime/qv4global_p.h index 9b13d4e341..1fa4bae049 100644 --- a/src/qml/jsruntime/qv4global_p.h +++ b/src/qml/jsruntime/qv4global_p.h @@ -101,7 +101,7 @@ inline double trunc(double d) { return d > 0 ? floor(d) : ceil(d); } # define V4_ENABLE_JIT # endif #elif defined(Q_PROCESSOR_ARM_64) && (QT_POINTER_SIZE == 8) -# if defined(Q_OS_LINUX) || defined(Q_OS_QNX) +# if defined(Q_OS_LINUX) || defined(Q_OS_QNX) || defined(Q_OS_INTEGRITY) # define V4_ENABLE_JIT # endif //#elif defined(Q_PROCESSOR_MIPS_32) && defined(Q_OS_LINUX) diff --git a/src/qml/jsruntime/qv4qobjectwrapper.cpp b/src/qml/jsruntime/qv4qobjectwrapper.cpp index 816c259b9b..d63d42478a 100644 --- a/src/qml/jsruntime/qv4qobjectwrapper.cpp +++ b/src/qml/jsruntime/qv4qobjectwrapper.cpp @@ -102,10 +102,10 @@ QPair<QObject *, int> QObjectMethod::extractQtMethod(const QV4::FunctionObject * return qMakePair((QObject *)nullptr, -1); } -static QPair<QObject *, int> extractQtSignal(const Value &value) +static QPair<QObject *, int> extractQtSignal(const QV4::Value &value) { if (value.isObject()) { - QV4::ExecutionEngine *v4 = value.as<Object>()->engine(); + QV4::ExecutionEngine *v4 = value.as<QV4::Object>()->engine(); QV4::Scope scope(v4); QV4::ScopedFunctionObject function(scope, value); if (function) @@ -1106,7 +1106,7 @@ struct CallArgument { inline void *dataPtr(); inline void initAsType(int type); - inline void fromValue(int type, ExecutionEngine *, const Value &); + inline void fromValue(int type, ExecutionEngine *, const QV4::Value &); inline ReturnedValue toValue(ExecutionEngine *); private: @@ -1304,7 +1304,7 @@ static int MatchScore(const QV4::Value &actual, int conversionType) return 10; } } - } else if (const Object *obj = actual.as<Object>()) { + } else if (const QV4::Object *obj = actual.as<QV4::Object>()) { if (obj->as<QV4::VariantObject>()) { if (conversionType == qMetaTypeId<QVariant>()) return 0; @@ -1720,7 +1720,7 @@ void CallArgument::fromValue(int callType, QV4::ExecutionEngine *engine, const Q || callType == qMetaTypeId<std::vector<QUrl>>() || callType == qMetaTypeId<std::vector<QModelIndex>>()) { queryEngine = true; - const QV4::Object* object = value.as<Object>(); + const QV4::Object* object = value.as<QV4::Object>(); if (callType == qMetaTypeId<std::vector<int>>()) { stdVectorIntPtr = nullptr; fromContainerValue<std::vector<int>>(object, callType, &CallArgument::stdVectorIntPtr, queryEngine); diff --git a/src/qml/jsruntime/qv4stringobject.cpp b/src/qml/jsruntime/qv4stringobject.cpp index e5a02fdc22..61176b3706 100644 --- a/src/qml/jsruntime/qv4stringobject.cpp +++ b/src/qml/jsruntime/qv4stringobject.cpp @@ -200,7 +200,7 @@ void StringPrototype::init(ExecutionEngine *engine, Object *ctor) defineDefaultProperty(QStringLiteral("trim"), method_trim); } -static Heap::String *thisAsString(ExecutionEngine *v4, const Value *thisObject) +static Heap::String *thisAsString(ExecutionEngine *v4, const QV4::Value *thisObject) { if (String *s = thisObject->stringValue()) return s->d(); @@ -209,7 +209,7 @@ static Heap::String *thisAsString(ExecutionEngine *v4, const Value *thisObject) return thisObject->toString(v4); } -static QString getThisString(ExecutionEngine *v4, const Value *thisObject) +static QString getThisString(ExecutionEngine *v4, const QV4::Value *thisObject) { if (String *s = thisObject->stringValue()) return s->toQString(); diff --git a/src/qml/jsruntime/qv4vme_moth.cpp b/src/qml/jsruntime/qv4vme_moth.cpp index e73365e9b1..a1f5b01fa9 100644 --- a/src/qml/jsruntime/qv4vme_moth.cpp +++ b/src/qml/jsruntime/qv4vme_moth.cpp @@ -345,7 +345,7 @@ static struct InstrCount { if (engine->hasException) \ goto catchException -static inline Heap::CallContext *getScope(Value *stack, int level) +static inline Heap::CallContext *getScope(QV4::Value *stack, int level) { Heap::ExecutionContext *scope = static_cast<ExecutionContext &>(stack[CallData::Context]).d(); while (level > 0) { @@ -362,7 +362,7 @@ static inline const QV4::Value &constant(Function *function, int index) } -static bool compareEqual(Value lhs, Value rhs) +static bool compareEqual(QV4::Value lhs, QV4::Value rhs) { redo: if (lhs.asReturnedValue() == rhs.asReturnedValue()) @@ -376,22 +376,22 @@ static bool compareEqual(Value lhs, Value rhs) } switch (lt) { - case Value::QT_ManagedOrUndefined: + case QV4::Value::QT_ManagedOrUndefined: if (lhs.isUndefined()) return rhs.isNullOrUndefined(); Q_FALLTHROUGH(); - case Value::QT_ManagedOrUndefined1: - case Value::QT_ManagedOrUndefined2: - case Value::QT_ManagedOrUndefined3: + case QV4::Value::QT_ManagedOrUndefined1: + case QV4::Value::QT_ManagedOrUndefined2: + case QV4::Value::QT_ManagedOrUndefined3: // LHS: Managed switch (rt) { - case Value::QT_ManagedOrUndefined: + case QV4::Value::QT_ManagedOrUndefined: if (rhs.isUndefined()) return false; Q_FALLTHROUGH(); - case Value::QT_ManagedOrUndefined1: - case Value::QT_ManagedOrUndefined2: - case Value::QT_ManagedOrUndefined3: { + case QV4::Value::QT_ManagedOrUndefined1: + case QV4::Value::QT_ManagedOrUndefined2: + case QV4::Value::QT_ManagedOrUndefined3: { // RHS: Managed Heap::Base *l = lhs.m(); Heap::Base *r = rhs.m(); @@ -409,12 +409,12 @@ static bool compareEqual(Value lhs, Value rhs) } return false; } - case Value::QT_Empty: + case QV4::Value::QT_Empty: Q_UNREACHABLE(); - case Value::QT_Null: + case QV4::Value::QT_Null: return false; - case Value::QT_Bool: - case Value::QT_Int: + case QV4::Value::QT_Bool: + case QV4::Value::QT_Int: rhs = Primitive::fromDouble(rhs.int_32()); // fall through default: // double @@ -424,22 +424,22 @@ static bool compareEqual(Value lhs, Value rhs) lhs = Primitive::fromReturnedValue(RuntimeHelpers::objectDefaultValue(&static_cast<QV4::Object &>(lhs), PREFERREDTYPE_HINT)); } goto redo; - case Value::QT_Empty: + case QV4::Value::QT_Empty: Q_UNREACHABLE(); - case Value::QT_Null: + case QV4::Value::QT_Null: return rhs.isNull(); - case Value::QT_Bool: - case Value::QT_Int: + case QV4::Value::QT_Bool: + case QV4::Value::QT_Int: switch (rt) { - case Value::QT_ManagedOrUndefined: - case Value::QT_ManagedOrUndefined1: - case Value::QT_ManagedOrUndefined2: - case Value::QT_ManagedOrUndefined3: - case Value::QT_Empty: - case Value::QT_Null: + case QV4::Value::QT_ManagedOrUndefined: + case QV4::Value::QT_ManagedOrUndefined1: + case QV4::Value::QT_ManagedOrUndefined2: + case QV4::Value::QT_ManagedOrUndefined3: + case QV4::Value::QT_Empty: + case QV4::Value::QT_Null: Q_UNREACHABLE(); - case Value::QT_Bool: - case Value::QT_Int: + case QV4::Value::QT_Bool: + case QV4::Value::QT_Int: return lhs.int_32() == rhs.int_32(); default: // double return lhs.int_32() == rhs.doubleValue(); @@ -450,29 +450,29 @@ static bool compareEqual(Value lhs, Value rhs) } } -static bool compareEqualInt(Value &accumulator, Value lhs, int rhs) +static bool compareEqualInt(QV4::Value &accumulator, QV4::Value lhs, int rhs) { redo: switch (lhs.quickType()) { - case Value::QT_ManagedOrUndefined: + case QV4::Value::QT_ManagedOrUndefined: if (lhs.isUndefined()) return false; Q_FALLTHROUGH(); - case Value::QT_ManagedOrUndefined1: - case Value::QT_ManagedOrUndefined2: - case Value::QT_ManagedOrUndefined3: + case QV4::Value::QT_ManagedOrUndefined1: + case QV4::Value::QT_ManagedOrUndefined2: + case QV4::Value::QT_ManagedOrUndefined3: // LHS: Managed if (lhs.m()->vtable()->isString) return RuntimeHelpers::stringToNumber(static_cast<String &>(lhs).toQString()) == rhs; accumulator = lhs; lhs = Primitive::fromReturnedValue(RuntimeHelpers::objectDefaultValue(&static_cast<QV4::Object &>(accumulator), PREFERREDTYPE_HINT)); goto redo; - case Value::QT_Empty: + case QV4::Value::QT_Empty: Q_UNREACHABLE(); - case Value::QT_Null: + case QV4::Value::QT_Null: return false; - case Value::QT_Bool: - case Value::QT_Int: + case QV4::Value::QT_Bool: + case QV4::Value::QT_Int: return lhs.int_32() == rhs; default: // double return lhs.doubleValue() == rhs; @@ -500,11 +500,11 @@ static bool compareEqualInt(Value &accumulator, Value lhs, int rhs) } \ } while (false) -QV4::ReturnedValue VME::exec(const FunctionObject *fo, const Value *thisObject, const Value *argv, int argc) +QV4::ReturnedValue VME::exec(const FunctionObject *fo, const QV4::Value *thisObject, const QV4::Value *argv, int argc) { qt_v4ResolvePendingBreakpointsHook(); ExecutionEngine *engine; - Value *stack; + QV4::Value *stack; CppStackFrame frame; frame.originalArguments = argv; frame.originalArgumentsCount = argc; diff --git a/src/qml/qml/qqmlcontext.cpp b/src/qml/qml/qqmlcontext.cpp index 5dd3278b4c..3dcfa92416 100644 --- a/src/qml/qml/qqmlcontext.cpp +++ b/src/qml/qml/qqmlcontext.cpp @@ -536,7 +536,7 @@ QQmlContextData::QQmlContextData() QQmlContextData::QQmlContextData(QQmlContext *ctxt) : engine(nullptr), isInternal(false), isJSContext(false), isPragmaLibraryContext(false), unresolvedNames(false), hasEmittedDestruction(false), isRootObjectInCreation(false), - publicContext(ctxt), incubator(nullptr), componentObjectIndex(-1), + stronglyReferencedByParent(false), publicContext(ctxt), incubator(nullptr), componentObjectIndex(-1), contextObject(nullptr), nextChild(nullptr), prevChild(nullptr), expressions(nullptr), contextObjects(nullptr), idValues(nullptr), idValueCount(0), componentAttached(nullptr) @@ -577,7 +577,10 @@ void QQmlContextData::invalidate() while (childContexts) { Q_ASSERT(childContexts != this); - childContexts->invalidate(); + if (childContexts->stronglyReferencedByParent && !--childContexts->refCount) + childContexts->destroy(); + else + childContexts->invalidate(); } if (prevChild) { @@ -672,12 +675,16 @@ void QQmlContextData::destroy() delete this; } -void QQmlContextData::setParent(QQmlContextData *p) +void QQmlContextData::setParent(QQmlContextData *p, bool stronglyReferencedByParent) { if (p == parent) return; if (p) { + Q_ASSERT(!parent); parent = p; + this->stronglyReferencedByParent = stronglyReferencedByParent; + if (stronglyReferencedByParent) + ++refCount; // balanced in QQmlContextData::invalidate() engine = p->engine; nextChild = p->childContexts; if (nextChild) nextChild->prevChild = &nextChild; diff --git a/src/qml/qml/qqmlcontext_p.h b/src/qml/qml/qqmlcontext_p.h index 5dfee48848..290b7fc7ee 100644 --- a/src/qml/qml/qqmlcontext_p.h +++ b/src/qml/qml/qqmlcontext_p.h @@ -126,7 +126,7 @@ public: QQmlContextData *parent = nullptr; QQmlEngine *engine; - void setParent(QQmlContextData *); + void setParent(QQmlContextData *, bool stronglyReferencedByParent = false); void refreshExpressions(); void addObject(QObject *); @@ -144,7 +144,8 @@ public: quint32 unresolvedNames:1; // True if expressions in this context failed to resolve a toplevel name quint32 hasEmittedDestruction:1; quint32 isRootObjectInCreation:1; - quint32 dummy:26; + quint32 stronglyReferencedByParent:1; + quint32 dummy:25; QQmlContext *publicContext; // The incubator that is constructing this context if any diff --git a/src/qml/qml/qqmlengine.cpp b/src/qml/qml/qqmlengine.cpp index 7e11177caa..b27bf3779a 100644 --- a/src/qml/qml/qqmlengine.cpp +++ b/src/qml/qml/qqmlengine.cpp @@ -1196,6 +1196,8 @@ void QQmlEnginePrivate::registerFinalizeCallback(QObject *obj, int index) support. The factory must be set before executing the engine. + + \note QQmlEngine does not take ownership of the factory. */ void QQmlEngine::setNetworkAccessManagerFactory(QQmlNetworkAccessManagerFactory *factory) { diff --git a/src/qml/qml/qqmlmetatype.cpp b/src/qml/qml/qqmlmetatype.cpp index 8fda7f6f77..d842a7795f 100644 --- a/src/qml/qml/qqmlmetatype.cpp +++ b/src/qml/qml/qqmlmetatype.cpp @@ -424,7 +424,7 @@ QQmlType::QQmlType(QQmlMetaTypeData *data, const QString &elementName, const QQm d->version_min = type.versionMinor; d->extraData.sd->singletonInstanceInfo = new SingletonInstanceInfo; - d->extraData.sd->singletonInstanceInfo->url = type.url; + d->extraData.sd->singletonInstanceInfo->url = QQmlTypeLoader::normalize(type.url); d->extraData.sd->singletonInstanceInfo->typeName = QString::fromUtf8(type.typeName); } @@ -477,7 +477,7 @@ QQmlType::QQmlType(QQmlMetaTypeData *data, const QString &elementName, const QQm d->version_maj = type.versionMajor; d->version_min = type.versionMinor; - d->extraData.fd->url = type.url; + d->extraData.fd->url = QQmlTypeLoader::normalize(type.url); } QQmlType::QQmlType() @@ -1710,7 +1710,7 @@ QQmlType QQmlMetaType::registerCompositeSingletonType(const QQmlPrivate::Registe addTypeToData(dtype.priv(), data); QQmlMetaTypeData::Files *files = fileImport ? &(data->urlToType) : &(data->urlToNonFileImportType); - files->insertMulti(type.url, dtype.priv()); + files->insertMulti(QQmlTypeLoader::normalize(type.url), dtype.priv()); return dtype; } @@ -1731,7 +1731,7 @@ QQmlType QQmlMetaType::registerCompositeType(const QQmlPrivate::RegisterComposit addTypeToData(dtype.priv(), data); QQmlMetaTypeData::Files *files = fileImport ? &(data->urlToType) : &(data->urlToNonFileImportType); - files->insertMulti(type.url, dtype.priv()); + files->insertMulti(QQmlTypeLoader::normalize(type.url), dtype.priv()); return dtype; } @@ -2253,8 +2253,9 @@ QQmlType QQmlMetaType::qmlType(int userType) Returns null if no such type is registered. */ -QQmlType QQmlMetaType::qmlType(const QUrl &url, bool includeNonFileImports /* = false */) +QQmlType QQmlMetaType::qmlType(const QUrl &unNormalizedUrl, bool includeNonFileImports /* = false */) { + const QUrl url = QQmlTypeLoader::normalize(unNormalizedUrl); QMutexLocker lock(metaTypeDataLock()); QQmlMetaTypeData *data = metaTypeData(); diff --git a/src/qml/qml/qqmlmetatype_p.h b/src/qml/qml/qqmlmetatype_p.h index cd7afc8a01..51bf485a3e 100644 --- a/src/qml/qml/qqmlmetatype_p.h +++ b/src/qml/qml/qqmlmetatype_p.h @@ -96,7 +96,7 @@ public: static QQmlType qmlType(const QMetaObject *); static QQmlType qmlType(const QMetaObject *metaObject, const QHashedStringRef &module, int version_major, int version_minor); static QQmlType qmlType(int); - static QQmlType qmlType(const QUrl &url, bool includeNonFileImports = false); + static QQmlType qmlType(const QUrl &unNormalizedUrl, bool includeNonFileImports = false); static QQmlPropertyCache *propertyCache(const QMetaObject *metaObject); static QQmlPropertyCache *propertyCache(const QQmlType &type, int minorVersion); diff --git a/src/qml/qml/qqmlobjectcreator.cpp b/src/qml/qml/qqmlobjectcreator.cpp index 7051fb51da..5aaf79c9e5 100644 --- a/src/qml/qml/qqmlobjectcreator.cpp +++ b/src/qml/qml/qqmlobjectcreator.cpp @@ -1217,9 +1217,9 @@ QObject *QQmlObjectCreator::createInstance(int index, QObject *parent, bool isCo } ddata = QQmlData::get(instance, /*create*/true); - ddata->lineNumber = obj->location.line; - ddata->columnNumber = obj->location.column; } + ddata->lineNumber = obj->location.line; + ddata->columnNumber = obj->location.column; ddata->setImplicitDestructible(); if (static_cast<quint32>(index) == /*root object*/0 || ddata->rootObjectInCreation) { diff --git a/src/qml/qml/qqmltypeloader.cpp b/src/qml/qml/qqmltypeloader.cpp index 5572fdad44..9856a0be80 100644 --- a/src/qml/qml/qqmltypeloader.cpp +++ b/src/qml/qml/qqmltypeloader.cpp @@ -1650,14 +1650,24 @@ QQmlImportDatabase *QQmlTypeLoader::importDatabase() const return &QQmlEnginePrivate::get(engine())->importDatabase; } +QUrl QQmlTypeLoader::normalize(const QUrl &unNormalizedUrl) +{ + QUrl normalized(unNormalizedUrl); + if (normalized.scheme() == QLatin1String("qrc")) + normalized.setHost(QString()); // map qrc:///a.qml to qrc:/a.qml + return normalized; +} + /*! Returns a QQmlTypeData for the specified \a url. The QQmlTypeData may be cached. */ -QQmlTypeData *QQmlTypeLoader::getType(const QUrl &url, Mode mode) +QQmlTypeData *QQmlTypeLoader::getType(const QUrl &unNormalizedUrl, Mode mode) { - Q_ASSERT(!url.isRelative() && - (QQmlFile::urlToLocalFileOrQrc(url).isEmpty() || - !QDir::isRelativePath(QQmlFile::urlToLocalFileOrQrc(url)))); + Q_ASSERT(!unNormalizedUrl.isRelative() && + (QQmlFile::urlToLocalFileOrQrc(unNormalizedUrl).isEmpty() || + !QDir::isRelativePath(QQmlFile::urlToLocalFileOrQrc(unNormalizedUrl)))); + + const QUrl url = normalize(unNormalizedUrl); LockHolder<QQmlTypeLoader> holder(this); @@ -1716,11 +1726,13 @@ QQmlTypeData *QQmlTypeLoader::getType(const QByteArray &data, const QUrl &url, M /*! Return a QQmlScriptBlob for \a url. The QQmlScriptData may be cached. */ -QQmlScriptBlob *QQmlTypeLoader::getScript(const QUrl &url) +QQmlScriptBlob *QQmlTypeLoader::getScript(const QUrl &unNormalizedUrl) { - Q_ASSERT(!url.isRelative() && - (QQmlFile::urlToLocalFileOrQrc(url).isEmpty() || - !QDir::isRelativePath(QQmlFile::urlToLocalFileOrQrc(url)))); + Q_ASSERT(!unNormalizedUrl.isRelative() && + (QQmlFile::urlToLocalFileOrQrc(unNormalizedUrl).isEmpty() || + !QDir::isRelativePath(QQmlFile::urlToLocalFileOrQrc(unNormalizedUrl)))); + + const QUrl url = normalize(unNormalizedUrl); LockHolder<QQmlTypeLoader> holder(this); diff --git a/src/qml/qml/qqmltypeloader_p.h b/src/qml/qml/qqmltypeloader_p.h index 5988632547..e75719866d 100644 --- a/src/qml/qml/qqmltypeloader_p.h +++ b/src/qml/qml/qqmltypeloader_p.h @@ -305,10 +305,12 @@ public: QQmlImportDatabase *importDatabase() const; - QQmlTypeData *getType(const QUrl &url, Mode mode = PreferSynchronous); + static QUrl normalize(const QUrl &unNormalizedUrl); + + QQmlTypeData *getType(const QUrl &unNormalizedUrl, Mode mode = PreferSynchronous); QQmlTypeData *getType(const QByteArray &, const QUrl &url, Mode mode = PreferSynchronous); - QQmlScriptBlob *getScript(const QUrl &); + QQmlScriptBlob *getScript(const QUrl &unNormalizedUrl); QQmlQmldirData *getQmldir(const QUrl &); QString absoluteFilePath(const QString &path); diff --git a/src/qml/types/qqmldelegatemodel.cpp b/src/qml/types/qqmldelegatemodel.cpp index 44166e4aa8..eb02e8045a 100644 --- a/src/qml/types/qqmldelegatemodel.cpp +++ b/src/qml/types/qqmldelegatemodel.cpp @@ -874,10 +874,11 @@ void QQmlDelegateModelPrivate::removeCacheItem(QQmlDelegateModelItem *cacheItem) void QQmlDelegateModelPrivate::incubatorStatusChanged(QQDMIncubationTask *incubationTask, QQmlIncubator::Status status) { - Q_Q(QQmlDelegateModel); if (!isDoneIncubating(status)) return; + const QList<QQmlError> incubationTaskErrors = incubationTask->errors(); + QQmlDelegateModelItem *cacheItem = incubationTask->incubating; cacheItem->incubationTask = nullptr; incubationTask->incubating = nullptr; @@ -891,7 +892,7 @@ void QQmlDelegateModelPrivate::incubatorStatusChanged(QQDMIncubationTask *incuba emitCreatedItem(incubationTask, cacheItem->object); cacheItem->releaseObject(); } else if (status == QQmlIncubator::Error) { - qmlWarning(q, m_delegate->errors()) << "Error creating delegate"; + qmlWarning(m_delegate, incubationTaskErrors + m_delegate->errors()) << "Error creating delegate"; } if (!cacheItem->isObjectReferenced()) { @@ -988,7 +989,7 @@ QObject *QQmlDelegateModelPrivate::object(Compositor::Group group, int index, QQ if (QQmlAdaptorModelProxyInterface *proxy = qobject_cast<QQmlAdaptorModelProxyInterface *>(cacheItem)) { ctxt = new QQmlContextData; - ctxt->setParent(cacheItem->contextData); + ctxt->setParent(cacheItem->contextData, /*stronglyReferencedByParent*/true); ctxt->contextObject = proxy->proxiedObject(); } } |