diff options
author | Aaron Kennedy <aaron.kennedy@nokia.com> | 2010-03-09 04:22:07 (GMT) |
---|---|---|
committer | Aaron Kennedy <aaron.kennedy@nokia.com> | 2010-03-09 04:22:07 (GMT) |
commit | 6a5891e7bfd182a52fd71f1b5fdf4d73def63603 (patch) | |
tree | 483385969c470974d505c32184620add5f841d5c /src/script/bridge | |
parent | c04a6e34b3d4da24d3cc26e192bebff2d3b79d19 (diff) | |
download | Qt-6a5891e7bfd182a52fd71f1b5fdf4d73def63603.zip Qt-6a5891e7bfd182a52fd71f1b5fdf4d73def63603.tar.gz Qt-6a5891e7bfd182a52fd71f1b5fdf4d73def63603.tar.bz2 |
Integrate QML's object ownership with the JS collector
QML now behaves in a way similar to QtScript when it comes to QObject
ownership.
QT-2803
Diffstat (limited to 'src/script/bridge')
-rw-r--r-- | src/script/bridge/qscriptdeclarativeclass.cpp | 5 | ||||
-rw-r--r-- | src/script/bridge/qscriptdeclarativeclass_p.h | 1 | ||||
-rw-r--r-- | src/script/bridge/qscriptdeclarativeobject.cpp | 17 | ||||
-rw-r--r-- | src/script/bridge/qscriptdeclarativeobject_p.h | 2 |
4 files changed, 25 insertions, 0 deletions
diff --git a/src/script/bridge/qscriptdeclarativeclass.cpp b/src/script/bridge/qscriptdeclarativeclass.cpp index 1d11ede..46c68ed 100644 --- a/src/script/bridge/qscriptdeclarativeclass.cpp +++ b/src/script/bridge/qscriptdeclarativeclass.cpp @@ -493,6 +493,11 @@ QScriptDeclarativeClass::Value QScriptDeclarativeClass::call(Object *object, return Value(); } +bool QScriptDeclarativeClass::compare(Object *o, Object *o2) +{ + return o == o2; +} + QStringList QScriptDeclarativeClass::propertyNames(Object *object) { Q_UNUSED(object); diff --git a/src/script/bridge/qscriptdeclarativeclass_p.h b/src/script/bridge/qscriptdeclarativeclass_p.h index a0fd6d5..7037e22 100644 --- a/src/script/bridge/qscriptdeclarativeclass_p.h +++ b/src/script/bridge/qscriptdeclarativeclass_p.h @@ -129,6 +129,7 @@ public: virtual void setProperty(Object *, const Identifier &name, const QScriptValue &); virtual QScriptValue::PropertyFlags propertyFlags(Object *, const Identifier &); virtual Value call(Object *, QScriptContext *); + virtual bool compare(Object *, Object *); virtual QStringList propertyNames(Object *); diff --git a/src/script/bridge/qscriptdeclarativeobject.cpp b/src/script/bridge/qscriptdeclarativeobject.cpp index c6ab6a7..70bb1bb 100644 --- a/src/script/bridge/qscriptdeclarativeobject.cpp +++ b/src/script/bridge/qscriptdeclarativeobject.cpp @@ -198,6 +198,23 @@ bool DeclarativeObjectDelegate::hasInstance(QScriptObject* object, JSC::ExecStat return QScriptObjectDelegate::hasInstance(object, exec, value, proto); } +bool DeclarativeObjectDelegate::compareToObject(QScriptObject *o, JSC::ExecState *exec, JSC::JSObject *o2) +{ + if (!o2->inherits(&QScriptObject::info)) + return false; + + QScriptObject *scriptObject = static_cast<QScriptObject*>(o2); + QScriptObjectDelegate *delegate = scriptObject->delegate(); + if (!delegate || (delegate->type() != QScriptObjectDelegate::DeclarativeClassObject)) + return false; + + DeclarativeObjectDelegate *other = static_cast<DeclarativeObjectDelegate*>(delegate); + if (m_class != other->m_class) + return false; + else + return m_class->compare(m_object, other->m_object); +} + } // namespace QScript QT_END_NAMESPACE diff --git a/src/script/bridge/qscriptdeclarativeobject_p.h b/src/script/bridge/qscriptdeclarativeobject_p.h index ec8a43e..878af24 100644 --- a/src/script/bridge/qscriptdeclarativeobject_p.h +++ b/src/script/bridge/qscriptdeclarativeobject_p.h @@ -99,6 +99,8 @@ public: virtual bool hasInstance(QScriptObject*, JSC::ExecState*, JSC::JSValue value, JSC::JSValue proto); + bool compareToObject(QScriptObject *, JSC::ExecState *, JSC::JSObject *); + private: QScriptDeclarativeClass *m_class; QScriptDeclarativeClass::Object *m_object; |