diff options
author | Aaron Kennedy <aaron.kennedy@nokia.com> | 2009-10-06 00:36:07 (GMT) |
---|---|---|
committer | Aaron Kennedy <aaron.kennedy@nokia.com> | 2009-10-06 00:36:07 (GMT) |
commit | 54e8e22a49148b089fd02895ead5c27aaf62e18e (patch) | |
tree | 71495fe7251b00c5dd103f95092eb111d845dcef /src/declarative/qml | |
parent | b411c4db37bcbb5152bf8e8b225e259c05c46b59 (diff) | |
download | Qt-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')
-rw-r--r-- | src/declarative/qml/qmldeclarativedata_p.h | 2 | ||||
-rw-r--r-- | src/declarative/qml/qmlobjectscriptclass.cpp | 11 |
2 files changed, 12 insertions, 1 deletions
diff --git a/src/declarative/qml/qmldeclarativedata_p.h b/src/declarative/qml/qmldeclarativedata_p.h index b4c87b8..f6ecc3d 100644 --- a/src/declarative/qml/qmldeclarativedata_p.h +++ b/src/declarative/qml/qmldeclarativedata_p.h @@ -54,6 +54,7 @@ // #include <private/qobject_p.h> +#include <QtScript/qscriptvalue.h> QT_BEGIN_NAMESPACE @@ -86,6 +87,7 @@ public: QHash<int, QObject *> *attachedProperties; + QScriptValue scriptValue; QmlPropertyCache *propertyCache; static QmlDeclarativeData *get(const QObject *object, bool create = false) { 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 |