aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4qobjectwrapper.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/qml/jsruntime/qv4qobjectwrapper.cpp')
-rw-r--r--src/qml/jsruntime/qv4qobjectwrapper.cpp58
1 files changed, 36 insertions, 22 deletions
diff --git a/src/qml/jsruntime/qv4qobjectwrapper.cpp b/src/qml/jsruntime/qv4qobjectwrapper.cpp
index b901d9be85..295b3413da 100644
--- a/src/qml/jsruntime/qv4qobjectwrapper.cpp
+++ b/src/qml/jsruntime/qv4qobjectwrapper.cpp
@@ -195,8 +195,9 @@ static QV4::ReturnedValue loadProperty(QV4::ExecutionEngine *v4, QObject *object
}
}
-Heap::QObjectWrapper::QObjectWrapper(QObject *object)
+void Heap::QObjectWrapper::init(QObject *object)
{
+ Object::init();
qObj.init(object);
}
@@ -613,8 +614,14 @@ bool QObjectWrapper::isEqualTo(Managed *a, Managed *b)
ReturnedValue QObjectWrapper::create(ExecutionEngine *engine, QObject *object)
{
- if (engine->jsEngine())
- QQmlData::ensurePropertyCache(engine->jsEngine(), object);
+ if (QJSEngine *jsEngine = engine->jsEngine()) {
+ if (QQmlPropertyCache *cache = QQmlData::ensurePropertyCache(jsEngine, object)) {
+ ReturnedValue result = QV4::Encode::null();
+ void *args[] = { &result, &engine };
+ if (cache->callJSFactoryMethod(object, args))
+ return result;
+ }
+ }
return (engine->memoryManager->allocObject<QV4::QObjectWrapper>(object))->asReturnedValue();
}
@@ -978,6 +985,10 @@ void QObjectWrapper::destroyObject(bool lastCall)
delete h->object();
else
h->object()->deleteLater();
+ } else {
+ // If the object is C++-owned, we still have to release the weak reference we have
+ // to it.
+ ddata->jsWrapper.clear();
}
}
}
@@ -1678,7 +1689,7 @@ ReturnedValue QObjectMethod::create(ExecutionContext *scope, QObject *object, in
method->d()->setObject(object);
if (QQmlData *ddata = QQmlData::get(object))
- method->d()->propertyCache = ddata->propertyCache;
+ method->d()->setPropertyCache(ddata->propertyCache);
method->d()->index = index;
return method.asReturnedValue();
@@ -1688,21 +1699,21 @@ ReturnedValue QObjectMethod::create(ExecutionContext *scope, const QQmlValueType
{
Scope valueScope(scope);
Scoped<QObjectMethod> method(valueScope, valueScope.engine->memoryManager->allocObject<QObjectMethod>(scope));
- method->d()->propertyCache = valueType->d()->propertyCache;
+ method->d()->setPropertyCache(valueType->d()->propertyCache());
method->d()->index = index;
method->d()->valueTypeWrapper = valueType->d();
return method.asReturnedValue();
}
-Heap::QObjectMethod::QObjectMethod(QV4::ExecutionContext *scope)
- : Heap::FunctionObject(scope)
+void Heap::QObjectMethod::init(QV4::ExecutionContext *scope)
{
+ Heap::FunctionObject::init(scope);
}
const QMetaObject *Heap::QObjectMethod::metaObject()
{
- if (propertyCache)
- return propertyCache->createMetaObject();
+ if (propertyCache())
+ return propertyCache()->createMetaObject();
return object()->metaObject();
}
@@ -1774,13 +1785,13 @@ void QObjectMethod::callInternal(CallData *callData, Scope &scope) const
return;
}
- object = QQmlObjectOrGadget(d()->propertyCache.data(), d()->valueTypeWrapper->gadgetPtr);
+ object = QQmlObjectOrGadget(d()->propertyCache(), d()->valueTypeWrapper->gadgetPtr);
}
QQmlPropertyData method;
- if (d()->propertyCache) {
- QQmlPropertyData *data = d()->propertyCache->method(d()->index);
+ if (d()->propertyCache()) {
+ QQmlPropertyData *data = d()->propertyCache()->method(d()->index);
if (!data) {
scope.result = QV4::Encode::undefined();
return;
@@ -1823,7 +1834,7 @@ void QObjectMethod::callInternal(CallData *callData, Scope &scope) const
if (!method.isOverload()) {
scope.result = CallPrecise(object, method, v4, callData);
} else {
- scope.result = CallOverloaded(object, method, v4, callData, d()->propertyCache);
+ scope.result = CallOverloaded(object, method, v4, callData, d()->propertyCache());
}
}
@@ -1839,13 +1850,15 @@ void QObjectMethod::markObjects(Heap::Base *that, ExecutionEngine *e)
DEFINE_OBJECT_VTABLE(QObjectMethod);
-Heap::QMetaObjectWrapper::QMetaObjectWrapper(const QMetaObject *metaObject)
- : metaObject(metaObject)
- , constructors(nullptr)
- , constructorCount(0)
-{}
+void Heap::QMetaObjectWrapper::init(const QMetaObject *metaObject)
+{
+ FunctionObject::init();
+ this->metaObject = metaObject;
+ constructors = nullptr;
+ constructorCount = 0;
+}
-Heap::QMetaObjectWrapper::~QMetaObjectWrapper()
+void Heap::QMetaObjectWrapper::destroy()
{
delete[] constructors;
}
@@ -2011,9 +2024,10 @@ DEFINE_OBJECT_VTABLE(QMetaObjectWrapper);
-Heap::QmlSignalHandler::QmlSignalHandler(QObject *object, int signalIndex)
- : signalIndex(signalIndex)
+void Heap::QmlSignalHandler::init(QObject *object, int signalIndex)
{
+ Object::init();
+ this->signalIndex = signalIndex;
setObject(object);
}
@@ -2021,7 +2035,7 @@ DEFINE_OBJECT_VTABLE(QmlSignalHandler);
void QmlSignalHandler::initProto(ExecutionEngine *engine)
{
- if (engine->signalHandlerPrototype()->d())
+ if (engine->signalHandlerPrototype()->d_unchecked())
return;
Scope scope(engine);