void QQmlVMEVariantQObjectPtr::objectDestroyed(QObject *)
{
if (m_target && m_index >= 0) {
- if (m_isVar && m_target->varPropertiesInitialized && !m_target->varProperties.isUndefined()) {
+ if (m_isVar && m_target->propertiesInitialized && !m_target->properties.isUndefined()) {
// Set the var property to NULL
- QV4::ExecutionEngine *v4 = m_target->varProperties.engine();
+ QV4::ExecutionEngine *v4 = m_target->properties.engine();
if (v4) {
QV4::Scope scope(v4);
- QV4::ScopedArrayObject a(scope, m_target->varProperties.value());
+ QV4::ScopedArrayObject a(scope, m_target->properties.value());
if (a)
- a->putIndexed(m_index - m_target->firstVarPropertyIndex, QV4::ScopedValue(scope, QV4::Primitive::nullValue()));
+ a->putIndexed(m_index, QV4::ScopedValue(scope, QV4::Primitive::nullValue()));
}
}
: object(obj),
ctxt(QQmlData::get(obj, true)->outerContext), cache(cache), metaData(meta),
hasAssignedMetaObjectData(false), data(0), aliasEndpoints(0), firstVarPropertyIndex(-1),
- varPropertiesInitialized(false), propertiesInitialized(false), interceptors(0), v8methods(0)
+ propertiesInitialized(false), interceptors(0), v8methods(0)
{
QObjectPrivate *op = QObjectPrivate::get(obj);
{
Q_ASSERT(id >= firstVarPropertyIndex);
- if (ensureVarPropertiesAllocated()) {
- QV4::Scope scope(varProperties.engine());
- QV4::ScopedObject o(scope, varProperties.value());
- return o->getIndexed(id - firstVarPropertyIndex);
+ if (ensurePropertiesAllocated()) {
+ QV4::Scope scope(properties.engine());
+ QV4::ScopedObject o(scope, properties.value());
+ return o->getIndexed(id);
}
return QV4::Primitive::undefinedValue().asReturnedValue();
}
QVariant QQmlVMEMetaObject::readPropertyAsVariant(int id)
{
if (id >= firstVarPropertyIndex) {
- if (ensureVarPropertiesAllocated()) {
- QV4::ExecutionEngine *v4 = varProperties.engine();
+ if (ensurePropertiesAllocated()) {
+ QV4::ExecutionEngine *v4 = properties.engine();
QV4::Scope scope(v4);
- QV4::ScopedObject o(scope, varProperties.value());
- QV4::ScopedValue val(scope, o->getIndexed(id - firstVarPropertyIndex));
+ QV4::ScopedObject o(scope, properties.value());
+ QV4::ScopedValue val(scope, o->getIndexed(id));
return scope.engine->toVariant(val, -1);
}
return QVariant();
void QQmlVMEMetaObject::writeVarProperty(int id, const QV4::Value &value)
{
Q_ASSERT(id >= firstVarPropertyIndex);
- if (!ensureVarPropertiesAllocated())
+ if (!ensurePropertiesAllocated())
return;
- QV4::Scope scope(varProperties.engine());
+ QV4::Scope scope(properties.engine());
// Importantly, if the current value is a scarce resource, we need to ensure that it
// gets automatically released by the engine if no other references to it exist.
- QV4::ScopedObject vp(scope, varProperties.value());
- QV4::Scoped<QV4::VariantObject> oldv(scope, vp->getIndexed(id - firstVarPropertyIndex));
+ QV4::ScopedObject vp(scope, properties.value());
+ QV4::Scoped<QV4::VariantObject> oldv(scope, vp->getIndexed(id));
if (!!oldv)
oldv->removeVmePropertyReference();
}
// Write the value and emit change signal as appropriate.
- vp->putIndexed(id - firstVarPropertyIndex, value);
+ vp->putIndexed(id, value);
activate(object, methodOffset() + id, 0);
}
void QQmlVMEMetaObject::writeProperty(int id, const QVariant &value)
{
if (id >= firstVarPropertyIndex) {
- if (!ensureVarPropertiesAllocated())
+ if (!ensurePropertiesAllocated())
return;
- QV4::Scope scope(varProperties.engine());
+ QV4::Scope scope(properties.engine());
// Importantly, if the current value is a scarce resource, we need to ensure that it
// gets automatically released by the engine if no other references to it exist.
- QV4::ScopedObject vp(scope, varProperties.value());
- QV4::Scoped<QV4::VariantObject> oldv(scope, vp->getIndexed(id - firstVarPropertyIndex));
+ QV4::ScopedObject vp(scope, properties.value());
+ QV4::Scoped<QV4::VariantObject> oldv(scope, vp->getIndexed(id));
if (!!oldv)
oldv->removeVmePropertyReference();
// Write the value and emit change signal as appropriate.
QVariant currentValue = readPropertyAsVariant(id);
- vp->putIndexed(id - firstVarPropertyIndex, newv);
+ vp->putIndexed(id, newv);
if ((currentValue.userType() != value.userType() || currentValue != value))
activate(object, methodOffset() + id, 0);
} else {
return writeVarProperty(index - propOffset(), v);
}
-bool QQmlVMEMetaObject::ensureVarPropertiesAllocated()
-{
- if (!varPropertiesInitialized)
- allocateVarPropertiesArray();
-
- // in some situations, the QObject's v8object (and associated v8 data,
- // such as the varProperties array) will have been cleaned up, but the
- // QObject ptr will not yet have been deleted (eg, waiting on deleteLater).
- // In this situation, the varProperties handle will be (and should remain)
- // empty.
- return !varProperties.isUndefined();
-}
-
bool QQmlVMEMetaObject::ensurePropertiesAllocated()
{
if (!propertiesInitialized)
- allocatePropertiesArray();
+ allocateProperties();
// in some situations, the QObject's v8object (and associated v8 data,
// such as the varProperties array) will have been cleaned up, but the
if (v4 != e)
return;
- varProperties.markOnce(e);
properties.markOnce(e);
// add references created by VMEVariant properties
parent->mark(e);
}
-void QQmlVMEMetaObject::allocateVarPropertiesArray()
-{
- QQmlEngine *qml = qmlEngine(object);
- Q_ASSERT(qml);
- QV4::ExecutionEngine *v4 = QV8Engine::getV4(qml->handle());
- QV4::Scope scope(v4);
- varProperties.set(scope.engine, v4->newArrayObject(metaData->varPropertyCount));
- varPropertiesInitialized = true;
-}
-
-void QQmlVMEMetaObject::allocatePropertiesArray()
+void QQmlVMEMetaObject::allocateProperties()
{
QQmlEngine *qml = qmlEngine(object);
Q_ASSERT(qml);
QV4::ExecutionEngine *v4 = QV8Engine::getV4(qml->handle());
QV4::Scope scope(v4);
- properties.set(scope.engine, v4->newArrayObject(metaData->propertyCount - metaData->varPropertyCount));
+ properties.set(scope.engine, v4->newArrayObject(metaData->propertyCount));
propertiesInitialized = true;
}
-
bool QQmlVMEMetaObject::aliasTarget(int index, QObject **target, int *coreIndex, int *valueTypeIndex) const
{
Q_ASSERT(index >= propOffset() + metaData->propertyCount);