summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/declarative/qml/qmlobjectscriptclass.cpp5
-rw-r--r--src/declarative/qml/qmlobjectscriptclass_p.h1
-rw-r--r--src/script/api/qscriptvalue.cpp12
-rw-r--r--src/script/bridge/qscriptdeclarativeclass.cpp5
-rw-r--r--src/script/bridge/qscriptdeclarativeclass_p.h1
5 files changed, 20 insertions, 4 deletions
diff --git a/src/declarative/qml/qmlobjectscriptclass.cpp b/src/declarative/qml/qmlobjectscriptclass.cpp
index 3d0581d..30d4422 100644
--- a/src/declarative/qml/qmlobjectscriptclass.cpp
+++ b/src/declarative/qml/qmlobjectscriptclass.cpp
@@ -306,6 +306,11 @@ void QmlObjectScriptClass::setProperty(QObject *obj,
QmlMetaPropertyPrivate::write(obj, *lastData, v, evalContext);
}
+bool QmlObjectScriptClass::isQObject() const
+{
+ return true;
+}
+
QObject *QmlObjectScriptClass::toQObject(Object *object, bool *ok)
{
if (ok) *ok = true;
diff --git a/src/declarative/qml/qmlobjectscriptclass_p.h b/src/declarative/qml/qmlobjectscriptclass_p.h
index 20c68ce..923be73 100644
--- a/src/declarative/qml/qmlobjectscriptclass_p.h
+++ b/src/declarative/qml/qmlobjectscriptclass_p.h
@@ -96,6 +96,7 @@ protected:
virtual QScriptValue property(Object *, const Identifier &);
virtual void setProperty(Object *, const Identifier &name, const QScriptValue &);
+ virtual bool isQObject() const;
virtual QObject *toQObject(Object *, bool *ok = 0);
private:
diff --git a/src/script/api/qscriptvalue.cpp b/src/script/api/qscriptvalue.cpp
index 286230f..b9be285 100644
--- a/src/script/api/qscriptvalue.cpp
+++ b/src/script/api/qscriptvalue.cpp
@@ -54,6 +54,7 @@
#include "bridge/qscriptvariant_p.h"
#include "bridge/qscriptqobject_p.h"
#include "bridge/qscriptdeclarativeclass_p.h"
+#include "bridge/qscriptdeclarativeobject_p.h"
/*!
\since 4.3
@@ -1570,9 +1571,10 @@ QObject *QScriptValue::toQObject() const
Q_D(const QScriptValue);
if (isQObject()) {
QScriptObject *object = static_cast<QScriptObject*>(JSC::asObject(d->jscValue));
- return static_cast<QScript::QObjectDelegate*>(object->delegate())->value();
- } else if (QScriptDeclarativeClass *dc = QScriptDeclarativeClass::scriptClass(*this)) {
- return dc->toQObject(QScriptDeclarativeClass::object(*this));
+ QScriptObjectDelegate *delegate = object->delegate();
+ if (delegate->type() == QScriptObjectDelegate::DeclarativeClassObject)
+ return static_cast<QScript::DeclarativeObjectDelegate*>(delegate)->scriptClass()->toQObject(QScriptDeclarativeClass::object(*this));
+ return static_cast<QScript::QObjectDelegate*>(delegate)->value();
} else if (isVariant()) {
QVariant var = toVariant();
int type = var.userType();
@@ -2245,7 +2247,9 @@ bool QScriptValue::isQObject() const
return false;
QScriptObject *object = static_cast<QScriptObject*>(JSC::asObject(d->jscValue));
QScriptObjectDelegate *delegate = object->delegate();
- return (delegate && (delegate->type() == QScriptObjectDelegate::QtObject));
+ return (delegate && (delegate->type() == QScriptObjectDelegate::QtObject ||
+ (delegate->type() == QScriptObjectDelegate::DeclarativeClassObject &&
+ static_cast<QScript::DeclarativeObjectDelegate*>(delegate)->scriptClass()->isQObject())));
}
/*!
diff --git a/src/script/bridge/qscriptdeclarativeclass.cpp b/src/script/bridge/qscriptdeclarativeclass.cpp
index 98b3e26..2c13066 100644
--- a/src/script/bridge/qscriptdeclarativeclass.cpp
+++ b/src/script/bridge/qscriptdeclarativeclass.cpp
@@ -320,6 +320,11 @@ QStringList QScriptDeclarativeClass::propertyNames(Object *object)
return QStringList();
}
+bool QScriptDeclarativeClass::isQObject() const
+{
+ return false;
+}
+
QObject *QScriptDeclarativeClass::toQObject(Object *, bool *ok)
{
if (ok) *ok = false;
diff --git a/src/script/bridge/qscriptdeclarativeclass_p.h b/src/script/bridge/qscriptdeclarativeclass_p.h
index 40e5051..f2557bd 100644
--- a/src/script/bridge/qscriptdeclarativeclass_p.h
+++ b/src/script/bridge/qscriptdeclarativeclass_p.h
@@ -97,6 +97,7 @@ public:
virtual QStringList propertyNames(Object *);
+ virtual bool isQObject() const;
virtual QObject *toQObject(Object *, bool *ok = 0);
virtual QVariant toVariant(Object *, bool *ok = 0);