summaryrefslogtreecommitdiffstats
path: root/src/declarative/qml/qmlobjectscriptclass.cpp
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2009-10-06 00:36:07 (GMT)
committerAaron Kennedy <aaron.kennedy@nokia.com>2009-10-06 00:36:07 (GMT)
commit54e8e22a49148b089fd02895ead5c27aaf62e18e (patch)
tree71495fe7251b00c5dd103f95092eb111d845dcef /src/declarative/qml/qmlobjectscriptclass.cpp
parentb411c4db37bcbb5152bf8e8b225e259c05c46b59 (diff)
downloadQt-54e8e22a49148b089fd02895ead5c27aaf62e18e.zip
Qt-54e8e22a49148b089fd02895ead5c27aaf62e18e.tar.gz
Qt-54e8e22a49148b089fd02895ead5c27aaf62e18e.tar.bz2
Share QScriptValue's where possible
Also add an autotest for object comparisons
Diffstat (limited to 'src/declarative/qml/qmlobjectscriptclass.cpp')
-rw-r--r--src/declarative/qml/qmlobjectscriptclass.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/declarative/qml/qmlobjectscriptclass.cpp b/src/declarative/qml/qmlobjectscriptclass.cpp
index 2d5991c..330eddd 100644
--- a/src/declarative/qml/qmlobjectscriptclass.cpp
+++ b/src/declarative/qml/qmlobjectscriptclass.cpp
@@ -80,7 +80,16 @@ QScriptValue QmlObjectScriptClass::newQObject(QObject *object)
{
QScriptEngine *scriptEngine = QmlEnginePrivate::getScriptEngine(engine);
- return newObject(scriptEngine, this, new ObjectData(object));
+ QmlDeclarativeData *ddata = QmlDeclarativeData::get(object, true);
+
+ if (!ddata->scriptValue.isValid()) {
+ ddata->scriptValue = newObject(scriptEngine, this, new ObjectData(object));
+ return ddata->scriptValue;
+ } else if (ddata->scriptValue.engine() == QmlEnginePrivate::getScriptEngine(engine)) {
+ return ddata->scriptValue;
+ } else {
+ return newObject(scriptEngine, this, new ObjectData(object));
+ }
}
QObject *QmlObjectScriptClass::toQObject(const QScriptValue &value) const