diff options
Diffstat (limited to 'src/qml/types')
-rw-r--r-- | src/qml/types/qqmldelegatemodel.cpp | 51 | ||||
-rw-r--r-- | src/qml/types/qqmldelegatemodel_p_p.h | 6 | ||||
-rw-r--r-- | src/qml/types/qqmllistmodel.cpp | 29 | ||||
-rw-r--r-- | src/qml/types/qqmllistmodel_p.h | 3 | ||||
-rw-r--r-- | src/qml/types/qqmllistmodel_p_p.h | 5 | ||||
-rw-r--r-- | src/qml/types/qquickworkerscript.cpp | 12 |
6 files changed, 46 insertions, 60 deletions
diff --git a/src/qml/types/qqmldelegatemodel.cpp b/src/qml/types/qqmldelegatemodel.cpp index 4e4a9353cb..ca19d68948 100644 --- a/src/qml/types/qqmldelegatemodel.cpp +++ b/src/qml/types/qqmldelegatemodel.cpp @@ -128,7 +128,8 @@ public: QQmlDelegateModelEngineData(QV4::ExecutionEngine *v4); ~QQmlDelegateModelEngineData(); - QV4::ReturnedValue array(QV8Engine *engine, const QVector<QQmlChangeSet::Change> &changes); + QV4::ReturnedValue array(QV4::ExecutionEngine *engine, + const QVector<QQmlChangeSet::Change> &changes); QV4::PersistentValue changeProto; }; @@ -325,7 +326,7 @@ void QQmlDelegateModel::componentComplete() } d->m_cacheMetaType = new QQmlDelegateModelItemMetaType( - QQmlEnginePrivate::getV8Engine(d->m_context->engine()), this, groupNames); + d->m_context->engine()->handle(), this, groupNames); d->m_compositor.setGroupCount(d->m_groupCount); d->m_compositor.setDefaultGroups(defaultGroups); @@ -1481,7 +1482,7 @@ void QQmlDelegateModelPrivate::emitChanges() return; m_transaction = true; - QV8Engine *engine = QQmlEnginePrivate::getV8Engine(m_context->engine()); + QV4::ExecutionEngine *engine = m_context->engine()->handle(); for (int i = 1; i < m_groupCount; ++i) QQmlDelegateModelGroupPrivate::get(m_groups[i])->emitChanges(engine); m_transaction = false; @@ -1676,10 +1677,10 @@ bool QQmlDelegateModelPrivate::insert(Compositor::insert_iterator &before, const //============================================================================ QQmlDelegateModelItemMetaType::QQmlDelegateModelItemMetaType( - QV8Engine *engine, QQmlDelegateModel *model, const QStringList &groupNames) + QV4::ExecutionEngine *engine, QQmlDelegateModel *model, const QStringList &groupNames) : model(model) , groupCount(groupNames.count() + 1) - , v8Engine(engine) + , v4Engine(engine) , metaObject(0) , groupNames(groupNames) { @@ -1720,37 +1721,36 @@ void QQmlDelegateModelItemMetaType::initializeMetaObject() void QQmlDelegateModelItemMetaType::initializePrototype() { - QV4::ExecutionEngine *v4 = QV8Engine::getV4(v8Engine); - QV4::Scope scope(v4); + QV4::Scope scope(v4Engine); - QV4::ScopedObject proto(scope, v4->newObject()); + QV4::ScopedObject proto(scope, v4Engine->newObject()); proto->defineAccessorProperty(QStringLiteral("model"), QQmlDelegateModelItem::get_model, 0); proto->defineAccessorProperty(QStringLiteral("groups"), QQmlDelegateModelItem::get_groups, QQmlDelegateModelItem::set_groups); QV4::ScopedString s(scope); QV4::ScopedProperty p(scope); - s = v4->newString(QStringLiteral("isUnresolved")); + s = v4Engine->newString(QStringLiteral("isUnresolved")); QV4::ScopedFunctionObject f(scope); QV4::ExecutionContext *global = scope.engine->rootContext(); p->setGetter((f = QV4::DelegateModelGroupFunction::create(global, 30, QQmlDelegateModelItem::get_member))); p->setSetter(0); proto->insertMember(s, p, QV4::Attr_Accessor|QV4::Attr_NotConfigurable|QV4::Attr_NotEnumerable); - s = v4->newString(QStringLiteral("inItems")); + s = v4Engine->newString(QStringLiteral("inItems")); p->setGetter((f = QV4::DelegateModelGroupFunction::create(global, QQmlListCompositor::Default, QQmlDelegateModelItem::get_member))); p->setSetter((f = QV4::DelegateModelGroupFunction::create(global, QQmlListCompositor::Default, QQmlDelegateModelItem::set_member))); proto->insertMember(s, p, QV4::Attr_Accessor|QV4::Attr_NotConfigurable|QV4::Attr_NotEnumerable); - s = v4->newString(QStringLiteral("inPersistedItems")); + s = v4Engine->newString(QStringLiteral("inPersistedItems")); p->setGetter((f = QV4::DelegateModelGroupFunction::create(global, QQmlListCompositor::Persisted, QQmlDelegateModelItem::get_member))); p->setSetter((f = QV4::DelegateModelGroupFunction::create(global, QQmlListCompositor::Persisted, QQmlDelegateModelItem::set_member))); proto->insertMember(s, p, QV4::Attr_Accessor|QV4::Attr_NotConfigurable|QV4::Attr_NotEnumerable); - s = v4->newString(QStringLiteral("itemsIndex")); + s = v4Engine->newString(QStringLiteral("itemsIndex")); p->setGetter((f = QV4::DelegateModelGroupFunction::create(global, QQmlListCompositor::Default, QQmlDelegateModelItem::get_index))); proto->insertMember(s, p, QV4::Attr_Accessor|QV4::Attr_NotConfigurable|QV4::Attr_NotEnumerable); - s = v4->newString(QStringLiteral("persistedItemsIndex")); + s = v4Engine->newString(QStringLiteral("persistedItemsIndex")); p->setGetter((f = QV4::DelegateModelGroupFunction::create(global, QQmlListCompositor::Persisted, QQmlDelegateModelItem::get_index))); p->setSetter(0); proto->insertMember(s, p, QV4::Attr_Accessor|QV4::Attr_NotConfigurable|QV4::Attr_NotEnumerable); @@ -1758,19 +1758,19 @@ void QQmlDelegateModelItemMetaType::initializePrototype() for (int i = 2; i < groupNames.count(); ++i) { QString propertyName = QLatin1String("in") + groupNames.at(i); propertyName.replace(2, 1, propertyName.at(2).toUpper()); - s = v4->newString(propertyName); + s = v4Engine->newString(propertyName); p->setGetter((f = QV4::DelegateModelGroupFunction::create(global, i + 1, QQmlDelegateModelItem::get_member))); p->setSetter((f = QV4::DelegateModelGroupFunction::create(global, i + 1, QQmlDelegateModelItem::set_member))); proto->insertMember(s, p, QV4::Attr_Accessor|QV4::Attr_NotConfigurable|QV4::Attr_NotEnumerable); } for (int i = 2; i < groupNames.count(); ++i) { const QString propertyName = groupNames.at(i) + QLatin1String("Index"); - s = v4->newString(propertyName); + s = v4Engine->newString(propertyName); p->setGetter((f = QV4::DelegateModelGroupFunction::create(global, i + 1, QQmlDelegateModelItem::get_index))); p->setSetter(0); proto->insertMember(s, p, QV4::Attr_Accessor|QV4::Attr_NotConfigurable|QV4::Attr_NotEnumerable); } - modelItemProto.set(v4, proto); + modelItemProto.set(v4Engine, proto); } int QQmlDelegateModelItemMetaType::parseGroups(const QStringList &groups) const @@ -1787,7 +1787,7 @@ int QQmlDelegateModelItemMetaType::parseGroups(const QStringList &groups) const int QQmlDelegateModelItemMetaType::parseGroups(const QV4::Value &groups) const { int groupFlags = 0; - QV4::Scope scope(QV8Engine::getV4(v8Engine)); + QV4::Scope scope(v4Engine); QV4::ScopedString s(scope, groups); if (s) { @@ -1907,7 +1907,7 @@ void QV4::Heap::QQmlDelegateModelItemObject::destroy() QQmlDelegateModelItem::QQmlDelegateModelItem( QQmlDelegateModelItemMetaType *metaType, int modelIndex) - : v4(QV8Engine::getV4(metaType->v8Engine)) + : v4(metaType->v4Engine) , metaType(metaType) , contextData(0) , object(0) @@ -2245,13 +2245,13 @@ bool QQmlDelegateModelGroupPrivate::isChangedConnected() IS_SIGNAL_CONNECTED(q, QQmlDelegateModelGroup, changed, (const QQmlV4Handle &,const QQmlV4Handle &)); } -void QQmlDelegateModelGroupPrivate::emitChanges(QV8Engine *engine) +void QQmlDelegateModelGroupPrivate::emitChanges(QV4::ExecutionEngine *v4) { Q_Q(QQmlDelegateModelGroup); if (isChangedConnected() && !changeSet.isEmpty()) { - QV4::Scope scope(QV8Engine::getV4(engine)); - QV4::ScopedValue removed(scope, engineData(scope.engine)->array(engine, changeSet.removes())); - QV4::ScopedValue inserted(scope, engineData(scope.engine)->array(engine, changeSet.inserts())); + QV4::Scope scope(v4); + QV4::ScopedValue removed(scope, engineData(scope.engine)->array(v4, changeSet.removes())); + QV4::ScopedValue inserted(scope, engineData(scope.engine)->array(v4, changeSet.inserts())); emit q->changed(QQmlV4Handle(removed), QQmlV4Handle(inserted)); } if (changeSet.difference() != 0) @@ -2480,8 +2480,7 @@ QQmlV4Handle QQmlDelegateModelGroup::get(int index) if (model->m_cacheMetaType->modelItemProto.isUndefined()) model->m_cacheMetaType->initializePrototype(); - QV8Engine *v8 = model->m_cacheMetaType->v8Engine; - QV4::ExecutionEngine *v4 = QV8Engine::getV4(v8); + QV4::ExecutionEngine *v4 = model->m_cacheMetaType->v4Engine; QV4::Scope scope(v4); QV4::ScopedObject o(scope, v4->memoryManager->allocObject<QQmlDelegateModelItemObject>(cacheItem)); QV4::ScopedObject p(scope, model->m_cacheMetaType->modelItemProto.value()); @@ -3347,9 +3346,9 @@ QQmlDelegateModelEngineData::~QQmlDelegateModelEngineData() { } -QV4::ReturnedValue QQmlDelegateModelEngineData::array(QV8Engine *engine, const QVector<QQmlChangeSet::Change> &changes) +QV4::ReturnedValue QQmlDelegateModelEngineData::array(QV4::ExecutionEngine *v4, + const QVector<QQmlChangeSet::Change> &changes) { - QV4::ExecutionEngine *v4 = QV8Engine::getV4(engine); QV4::Scope scope(v4); QV4::ScopedObject o(scope, QQmlDelegateModelGroupChangeArray::create(v4, changes)); return o.asReturnedValue(); diff --git a/src/qml/types/qqmldelegatemodel_p_p.h b/src/qml/types/qqmldelegatemodel_p_p.h index 537937df57..7b60bcddc0 100644 --- a/src/qml/types/qqmldelegatemodel_p_p.h +++ b/src/qml/types/qqmldelegatemodel_p_p.h @@ -69,7 +69,7 @@ class QQmlDelegateModelAttachedMetaObject; class QQmlDelegateModelItemMetaType : public QQmlRefCount { public: - QQmlDelegateModelItemMetaType(QV8Engine *engine, QQmlDelegateModel *model, const QStringList &groupNames); + QQmlDelegateModelItemMetaType(QV4::ExecutionEngine *engine, QQmlDelegateModel *model, const QStringList &groupNames); ~QQmlDelegateModelItemMetaType(); void initializeMetaObject(); @@ -80,7 +80,7 @@ public: QPointer<QQmlDelegateModel> model; const int groupCount; - QV8Engine * const v8Engine; + QV4::ExecutionEngine * const v4Engine; QQmlDelegateModelAttachedMetaObject *metaObject; const QStringList groupNames; QV4::PersistentValue modelItemProto; @@ -220,7 +220,7 @@ public: void setModel(QQmlDelegateModel *model, Compositor::Group group); bool isChangedConnected(); - void emitChanges(QV8Engine *engine); + void emitChanges(QV4::ExecutionEngine *engine); void emitModelUpdated(bool reset); void createdPackage(int index, QQuickPackage *package); diff --git a/src/qml/types/qqmllistmodel.cpp b/src/qml/types/qqmllistmodel.cpp index 0f04d48bf8..299de8de70 100644 --- a/src/qml/types/qqmllistmodel.cpp +++ b/src/qml/types/qqmllistmodel.cpp @@ -274,7 +274,6 @@ QObject *ListModel::getOrCreateModelObject(QQmlListModel *model, int elementInde bool ListModel::sync(ListModel *src, ListModel *target) { // Sanity check - target->m_uid = src->m_uid; bool hasChanges = false; @@ -391,11 +390,8 @@ bool ListModel::sync(ListModel *src, ListModel *target) return hasChanges; } -ListModel::ListModel(ListLayout *layout, QQmlListModel *modelCache, int uid) : m_layout(layout), m_modelCache(modelCache) +ListModel::ListModel(ListLayout *layout, QQmlListModel *modelCache) : m_layout(layout), m_modelCache(modelCache) { - if (uid == -1) - uid = uidCounter.fetchAndAddOrdered(1); - m_uid = uid; } void ListModel::destroy() @@ -403,7 +399,6 @@ void ListModel::destroy() for (const auto &destroyer : remove(0, elements.count())) destroyer(); - m_uid = -1; m_layout = 0; if (m_modelCache && m_modelCache->m_primary == false) delete m_modelCache; @@ -508,7 +503,7 @@ void ListModel::set(int elementIndex, QV4::Object *object, QVector<int> *roles) roleIndex = e->setDoubleProperty(r, propertyValue->asDouble()); } else if (QV4::ArrayObject *a = propertyValue->as<QV4::ArrayObject>()) { const ListLayout::Role &r = m_layout->getRoleOrCreate(propertyName, ListLayout::Role::List); - ListModel *subModel = new ListModel(r.subLayout, 0, -1); + ListModel *subModel = new ListModel(r.subLayout, 0); int arrayLength = a->getLength(); for (int j=0 ; j < arrayLength ; ++j) { @@ -589,7 +584,7 @@ void ListModel::set(int elementIndex, QV4::Object *object) } else if (QV4::ArrayObject *a = propertyValue->as<QV4::ArrayObject>()) { const ListLayout::Role &r = m_layout->getRoleOrCreate(propertyName, ListLayout::Role::List); if (r.type == ListLayout::Role::List) { - ListModel *subModel = new ListModel(r.subLayout, 0, -1); + ListModel *subModel = new ListModel(r.subLayout, 0); int arrayLength = a->getLength(); for (int j=0 ; j < arrayLength ; ++j) { @@ -1170,7 +1165,7 @@ QVector<int> ListElement::sync(ListElement *src, ListLayout *srcLayout, ListElem if (srcSubModel) { if (targetSubModel == 0) { - targetSubModel = new ListModel(targetRole.subLayout, 0, srcSubModel->getUid()); + targetSubModel = new ListModel(targetRole.subLayout, 0); target->setListPropertyFast(targetRole, targetSubModel); } if (ListModel::sync(srcSubModel, targetSubModel)) @@ -1329,7 +1324,7 @@ int ListElement::setJsProperty(const ListLayout::Role &role, const QV4::Value &d QV4::Scope scope(a->engine()); QV4::ScopedObject o(scope); - ListModel *subModel = new ListModel(role.subLayout, 0, -1); + ListModel *subModel = new ListModel(role.subLayout, 0); int arrayLength = a->getLength(); for (int j=0 ; j < arrayLength ; ++j) { o = a->getIndexed(j); @@ -1788,11 +1783,10 @@ QQmlListModel::QQmlListModel(QObject *parent) m_mainThread = true; m_primary = true; m_agent = 0; - m_uid = uidCounter.fetchAndAddOrdered(1); m_dynamicRoles = false; m_layout = new ListLayout; - m_listModel = new ListModel(m_layout, this, -1); + m_listModel = new ListModel(m_layout, this); m_engine = 0; } @@ -1821,7 +1815,7 @@ QQmlListModel::QQmlListModel(QQmlListModel *orig, QQmlListModelWorkerAgent *agen m_dynamicRoles = orig->m_dynamicRoles; m_layout = new ListLayout(orig->m_layout); - m_listModel = new ListModel(m_layout, this, orig->m_listModel->getUid()); + m_listModel = new ListModel(m_layout, this); if (m_dynamicRoles) sync(orig, this); @@ -1871,7 +1865,7 @@ QQmlListModel *QQmlListModel::createWithOwner(QQmlListModel *newOwner) QV4::ExecutionEngine *QQmlListModel::engine() const { if (m_engine == 0) { - m_engine = QQmlEnginePrivate::get(qmlEngine(this))->v4engine(); + m_engine = qmlEngine(this)->handle(); } return m_engine; @@ -1883,7 +1877,6 @@ bool QQmlListModel::sync(QQmlListModel *src, QQmlListModel *target) bool hasChanges = false; - target->m_uid = src->m_uid; target->m_roles = src->m_roles; // Build hash of elements <-> uid for each of the lists @@ -2611,7 +2604,7 @@ bool QQmlListModelParser::applyProperty(QV4::CompiledData::CompilationUnit *comp if (role.type == ListLayout::Role::List) { subModel = model->getListProperty(outterElementIndex, role); if (subModel == 0) { - subModel = new ListModel(role.subLayout, 0, -1); + subModel = new ListModel(role.subLayout, 0); QVariant vModel = QVariant::fromValue(subModel); model->setOrCreateProperty(outterElementIndex, elementName, vModel); } @@ -2638,7 +2631,7 @@ bool QQmlListModelParser::applyProperty(QV4::CompiledData::CompilationUnit *comp QString scriptStr = binding->valueAsScriptString(qmlUnit); if (definesEmptyList(scriptStr)) { const ListLayout::Role &role = model->getOrCreateListRole(elementName); - ListModel *emptyModel = new ListModel(role.subLayout, 0, -1); + ListModel *emptyModel = new ListModel(role.subLayout, 0); value = QVariant::fromValue(emptyModel); } else if (binding->isFunctionExpression()) { QQmlBinding::Identifier id = binding->value.compiledScriptIndex; @@ -2689,7 +2682,7 @@ void QQmlListModelParser::applyBindings(QObject *obj, QV4::CompiledData::Compila { QQmlListModel *rv = static_cast<QQmlListModel *>(obj); - rv->m_engine = QV8Engine::getV4(qmlEngine(rv)); + rv->m_engine = qmlEngine(rv)->handle(); const QV4::CompiledData::Unit *qmlUnit = compilationUnit->data; diff --git a/src/qml/types/qqmllistmodel_p.h b/src/qml/types/qqmllistmodel_p.h index 18b7b8bb22..cbb12caa20 100644 --- a/src/qml/types/qqmllistmodel_p.h +++ b/src/qml/types/qqmllistmodel_p.h @@ -143,7 +143,6 @@ private: QVector<class DynamicRoleModelNode *> m_modelObjects; QVector<QString> m_roles; - int m_uid; struct ElementSync { @@ -154,8 +153,6 @@ private: QVector<int> changedRoles; }; - int getUid() const { return m_uid; } - static bool sync(QQmlListModel *src, QQmlListModel *target); static QQmlListModel *createWithOwner(QQmlListModel *newOwner); diff --git a/src/qml/types/qqmllistmodel_p_p.h b/src/qml/types/qqmllistmodel_p_p.h index 65567ab69a..81b9956ecb 100644 --- a/src/qml/types/qqmllistmodel_p_p.h +++ b/src/qml/types/qqmllistmodel_p_p.h @@ -328,7 +328,7 @@ class ListModel { public: - ListModel(ListLayout *layout, QQmlListModel *modelCache, int uid); + ListModel(ListLayout *layout, QQmlListModel *modelCache); ~ListModel() {} void destroy(); @@ -377,8 +377,6 @@ public: void move(int from, int to, int n); - int getUid() const { return m_uid; } - static bool sync(ListModel *src, ListModel *target); QObject *getOrCreateModelObject(QQmlListModel *model, int elementIndex); @@ -386,7 +384,6 @@ public: private: QPODVector<ListElement *, 4> elements; ListLayout *m_layout; - int m_uid; QQmlListModel *m_modelCache; diff --git a/src/qml/types/qquickworkerscript.cpp b/src/qml/types/qquickworkerscript.cpp index 231c0fa810..32c0c86ff6 100644 --- a/src/qml/types/qquickworkerscript.cpp +++ b/src/qml/types/qquickworkerscript.cpp @@ -201,7 +201,7 @@ private: }; QQuickWorkerScriptEnginePrivate::WorkerEngine::WorkerEngine(QQuickWorkerScriptEnginePrivate *parent) -: QV8Engine(0), p(parent) + : QV8Engine(nullptr, new QV4::ExecutionEngine), p(parent) #if QT_CONFIG(qml_network) , accessManager(0) #endif @@ -214,6 +214,7 @@ QQuickWorkerScriptEnginePrivate::WorkerEngine::~WorkerEngine() #if QT_CONFIG(qml_network) delete accessManager; #endif + delete m_v4Engine; } void QQuickWorkerScriptEnginePrivate::WorkerEngine::init() @@ -250,7 +251,7 @@ void QQuickWorkerScriptEnginePrivate::WorkerEngine::init() QQuickWorkerScriptEnginePrivate::method_sendMessage)); QV4::JSCallData jsCallData(scope, 1); jsCallData->args[0] = function; - *jsCallData->thisObject = global(); + *jsCallData->thisObject = m_v4Engine->global(); createsend.set(scope.engine, createsendconstructor->call(jsCallData)); } @@ -267,7 +268,7 @@ QV4::ReturnedValue QQuickWorkerScriptEnginePrivate::WorkerEngine::sendFunction(i QV4::ScopedValue v(scope); QV4::JSCallData jsCallData(scope, 1); jsCallData->args[0] = QV4::Primitive::fromInt32(id); - *jsCallData->thisObject = global(); + *jsCallData->thisObject = m_v4Engine->global(); v = f->call(jsCallData); if (scope.hasException()) v = scope.engine->catchException(); @@ -367,7 +368,7 @@ void QQuickWorkerScriptEnginePrivate::processMessage(int id, const QByteArray &d Q_ASSERT(!!qmlContext); QV4::JSCallData jsCallData(scope, 2); - *jsCallData->thisObject = workerEngine->global(); + *jsCallData->thisObject = v4->global(); jsCallData->args[0] = qmlContext->d()->qml(); // ### jsCallData->args[1] = value; f->call(jsCallData); @@ -730,8 +731,7 @@ bool QQuickWorkerScript::event(QEvent *event) QQmlEngine *engine = qmlEngine(this); if (engine) { WorkerDataEvent *workerEvent = static_cast<WorkerDataEvent *>(event); - QV8Engine *v8engine = QQmlEnginePrivate::get(engine)->v8engine(); - QV4::Scope scope(QV8Engine::getV4(v8engine)); + QV4::Scope scope(engine->handle()); QV4::ScopedValue value(scope, QV4::Serialize::deserialize(workerEvent->data(), scope.engine)); emit message(QQmlV4Handle(value)); } |