From 61440411a979c7c317bafccfbf5201d969819a06 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Mon, 25 Jun 2018 23:18:33 +0200 Subject: Prefix vtable methods with virtual Turns out that the overloading of vtable methods and regular ones is problematic in some cases. So let's rather make it explicit which methods are part of the vtable, and which aren't. Change-Id: Ifee32a26104d30f3c82bca8b5a9cdea2d4f4f526 Reviewed-by: Simon Hausmann --- src/qml/types/qqmldelegatemodel.cpp | 6 +++--- src/qml/types/qqmllistmodel.cpp | 14 +++++++------- src/qml/types/qqmllistmodel_p_p.h | 9 +++++---- 3 files changed, 15 insertions(+), 14 deletions(-) (limited to 'src/qml/types') diff --git a/src/qml/types/qqmldelegatemodel.cpp b/src/qml/types/qqmldelegatemodel.cpp index 3058ac2069..0dbd9731c9 100644 --- a/src/qml/types/qqmldelegatemodel.cpp +++ b/src/qml/types/qqmldelegatemodel.cpp @@ -96,7 +96,7 @@ struct DelegateModelGroupFunction : QV4::FunctionObject return scope->engine()->memoryManager->allocate(scope, flag, code); } - static ReturnedValue call(const QV4::FunctionObject *that, const Value *thisObject, const Value *argv, int argc) + static ReturnedValue virtualCall(const QV4::FunctionObject *that, const Value *thisObject, const Value *argv, int argc) { QV4::Scope scope(that->engine()); QV4::Scoped f(scope, static_cast(that)); @@ -3383,7 +3383,7 @@ public: quint32 count() const { return d()->changes->count(); } const QQmlChangeSet::Change &at(int index) const { return d()->changes->at(index); } - static QV4::ReturnedValue get(const QV4::Managed *m, QV4::PropertyKey id, const QV4::Value *receiver, bool *hasProperty) + static QV4::ReturnedValue virtualGet(const QV4::Managed *m, QV4::PropertyKey id, const QV4::Value *receiver, bool *hasProperty) { if (id.isArrayIndex()) { uint index = id.asArrayIndex(); @@ -3419,7 +3419,7 @@ public: return QV4::Encode(array->count()); } - return Object::get(m, id, receiver, hasProperty); + return Object::virtualGet(m, id, receiver, hasProperty); } }; diff --git a/src/qml/types/qqmllistmodel.cpp b/src/qml/types/qqmllistmodel.cpp index 27e9df0c0b..2325eca469 100644 --- a/src/qml/types/qqmllistmodel.cpp +++ b/src/qml/types/qqmllistmodel.cpp @@ -1564,10 +1564,10 @@ void ModelNodeMetaObject::emitDirectNotifies(const int *changedRoles, int roleCo namespace QV4 { -bool ModelObject::put(Managed *m, PropertyKey id, const Value &value, Value *receiver) +bool ModelObject::virtualPut(Managed *m, PropertyKey id, const Value &value, Value *receiver) { if (!id.isString()) - return Object::put(m, id, value, receiver); + return Object::virtualPut(m, id, value, receiver); QString propName = id.toQString(); ModelObject *that = static_cast(m); @@ -1584,17 +1584,17 @@ bool ModelObject::put(Managed *m, PropertyKey id, const Value &value, Value *rec return true; } -ReturnedValue ModelObject::get(const Managed *m, PropertyKey id, const Value *receiver, bool *hasProperty) +ReturnedValue ModelObject::virtualGet(const Managed *m, PropertyKey id, const Value *receiver, bool *hasProperty) { if (!id.isString()) - return Object::get(m, id, receiver, hasProperty); + return QObjectWrapper::virtualGet(m, id, receiver, hasProperty); const ModelObject *that = static_cast(m); Scope scope(that); ScopedString name(scope, id.asStringOrSymbol()); const ListLayout::Role *role = that->d()->m_model->m_listModel->getExistingRole(name); if (!role) - return QObjectWrapper::get(m, id, receiver, hasProperty); + return QObjectWrapper::virtualGet(m, id, receiver, hasProperty); if (hasProperty) *hasProperty = true; @@ -1610,7 +1610,7 @@ ReturnedValue ModelObject::get(const Managed *m, PropertyKey id, const Value *re return that->engine()->fromVariant(value); } -void ModelObject::advanceIterator(Managed *m, ObjectIterator *it, Value *name, uint *index, Property *p, PropertyAttributes *attributes) +void ModelObject::virtualAdvanceIterator(Managed *m, ObjectIterator *it, Value *name, uint *index, Property *p, PropertyAttributes *attributes) { ModelObject *that = static_cast(m); ExecutionEngine *v4 = that->engine(); @@ -1630,7 +1630,7 @@ void ModelObject::advanceIterator(Managed *m, ObjectIterator *it, Value *name, u // Fall back to QV4::Object as opposed to QV4::QObjectWrapper otherwise it will add // unnecessary entries that relate to the roles used. These just create extra work // later on as they will just be ignored. - QV4::Object::advanceIterator(m, it, name, index, p, attributes); + QV4::Object::virtualAdvanceIterator(m, it, name, index, p, attributes); } DEFINE_OBJECT_VTABLE(ModelObject); diff --git a/src/qml/types/qqmllistmodel_p_p.h b/src/qml/types/qqmllistmodel_p_p.h index fe88877837..e4a850e8a5 100644 --- a/src/qml/types/qqmllistmodel_p_p.h +++ b/src/qml/types/qqmllistmodel_p_p.h @@ -173,12 +173,13 @@ struct ModelObject : public QObjectWrapper { struct ModelObject : public QObjectWrapper { - static bool put(Managed *m, PropertyKey id, const Value& value, Value *receiver); - static ReturnedValue get(const Managed *m, PropertyKey id, const Value *receiver, bool *hasProperty); - static void advanceIterator(Managed *m, ObjectIterator *it, Value *name, uint *index, Property *p, PropertyAttributes *attributes); - V4_OBJECT2(ModelObject, QObjectWrapper) V4_NEEDS_DESTROY + +protected: + static bool virtualPut(Managed *m, PropertyKey id, const Value& value, Value *receiver); + static ReturnedValue virtualGet(const Managed *m, PropertyKey id, const Value *receiver, bool *hasProperty); + static void virtualAdvanceIterator(Managed *m, ObjectIterator *it, Value *name, uint *index, Property *p, PropertyAttributes *attributes); }; } // namespace QV4 -- cgit v1.2.3