summaryrefslogtreecommitdiffstats
path: root/src/script/api/qscriptvalue.cpp
diff options
context:
space:
mode:
authorMichael Brasser <michael.brasser@nokia.com>2010-01-11 01:01:18 (GMT)
committerMichael Brasser <michael.brasser@nokia.com>2010-01-11 01:01:18 (GMT)
commit31cc1b382fbcd77def12cd0ad4fe9fc0fabdf60b (patch)
tree8ff8e1845d1ebf78507ffb0c52d33bda7f5ceeee /src/script/api/qscriptvalue.cpp
parent3f3e86d6fce5bb781bc41def35d0f15c58ef769c (diff)
downloadQt-31cc1b382fbcd77def12cd0ad4fe9fc0fabdf60b.zip
Qt-31cc1b382fbcd77def12cd0ad4fe9fc0fabdf60b.tar.gz
Qt-31cc1b382fbcd77def12cd0ad4fe9fc0fabdf60b.tar.bz2
Correctly determine QScriptValue::isQObject() for QObjects using the
QScriptDeclarativeClass. Task-number: QTBUG-6178 Reviewed-by: Kent Hansen Reviewed-by: Aaron Kennedy
Diffstat (limited to 'src/script/api/qscriptvalue.cpp')
-rw-r--r--src/script/api/qscriptvalue.cpp12
1 files changed, 8 insertions, 4 deletions
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())));
}
/*!