summaryrefslogtreecommitdiffstats
path: root/src/declarative/qml
diff options
context:
space:
mode:
Diffstat (limited to 'src/declarative/qml')
-rw-r--r--src/declarative/qml/qdeclarativedeclarativedata_p.h6
-rw-r--r--src/declarative/qml/qdeclarativeengine.cpp7
-rw-r--r--src/declarative/qml/qdeclarativeobjectscriptclass.cpp10
3 files changed, 13 insertions, 10 deletions
diff --git a/src/declarative/qml/qdeclarativedeclarativedata_p.h b/src/declarative/qml/qdeclarativedeclarativedata_p.h
index dfc3113..aea775b 100644
--- a/src/declarative/qml/qdeclarativedeclarativedata_p.h
+++ b/src/declarative/qml/qdeclarativedeclarativedata_p.h
@@ -75,7 +75,7 @@ public:
: ownMemory(true), ownContext(false), indestructible(true), explicitIndestructibleSet(false),
context(0), outerContext(0), bindings(0), nextContextObject(0), prevContextObject(0), bindingBitsSize(0),
bindingBits(0), lineNumber(0), columnNumber(0), deferredComponent(0), deferredIdx(0),
- attachedProperties(0), propertyCache(0), guards(0) {}
+ attachedProperties(0), scriptValue(0), propertyCache(0), guards(0) {}
void destroyed(QObject *);
void parentChanged(QObject *, QObject *);
@@ -113,7 +113,9 @@ public:
QHash<int, QObject *> *attachedProperties;
- QScriptValue scriptValue;
+ // ### Can we make this QScriptValuePrivate so we incur no additional allocation
+ // cost?
+ QScriptValue *scriptValue;
QDeclarativePropertyCache *propertyCache;
QDeclarativeGuard<QObject> *guards;
diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp
index 65dd72b..cf5fc3b 100644
--- a/src/declarative/qml/qdeclarativeengine.cpp
+++ b/src/declarative/qml/qdeclarativeengine.cpp
@@ -862,15 +862,16 @@ void QDeclarativeDeclarativeData::destroyed(QObject *object)
if (ownContext)
context->destroy();
+ if (scriptValue)
+ delete scriptValue;
+
if (ownMemory)
delete this;
- else
- this->~QDeclarativeDeclarativeData();
}
void QDeclarativeDeclarativeData::parentChanged(QObject *, QObject *parent)
{
- if (!parent && scriptValue.isValid()) scriptValue = QScriptValue();
+ if (!parent && scriptValue) { delete scriptValue; scriptValue = 0; }
}
bool QDeclarativeDeclarativeData::hasBindingBit(int bit) const
diff --git a/src/declarative/qml/qdeclarativeobjectscriptclass.cpp b/src/declarative/qml/qdeclarativeobjectscriptclass.cpp
index 84c9bef..1424508 100644
--- a/src/declarative/qml/qdeclarativeobjectscriptclass.cpp
+++ b/src/declarative/qml/qdeclarativeobjectscriptclass.cpp
@@ -109,11 +109,11 @@ QScriptValue QDeclarativeObjectScriptClass::newQObject(QObject *object, int type
return scriptEngine->undefinedValue();
} else if (!ddata->indestructible && !object->parent()) {
return newObject(scriptEngine, this, new ObjectData(object, type));
- } else if (!ddata->scriptValue.isValid()) {
- ddata->scriptValue = newObject(scriptEngine, this, new ObjectData(object, type));
- return ddata->scriptValue;
- } else if (ddata->scriptValue.engine() == QDeclarativeEnginePrivate::getScriptEngine(engine)) {
- return ddata->scriptValue;
+ } else if (!ddata->scriptValue) {
+ ddata->scriptValue = new QScriptValue(newObject(scriptEngine, this, new ObjectData(object, type)));
+ return *ddata->scriptValue;
+ } else if (ddata->scriptValue->engine() == QDeclarativeEnginePrivate::getScriptEngine(engine)) {
+ return *ddata->scriptValue;
} else {
return newObject(scriptEngine, this, new ObjectData(object, type));
}