summaryrefslogtreecommitdiffstats
path: root/src/script/bridge/qscriptqobject.cpp
diff options
context:
space:
mode:
authorJędrzej Nowacki <jedrzej.nowacki@nokia.com>2012-03-29 16:48:32 +0200
committerQt by Nokia <qt-info@nokia.com>2012-04-17 16:59:02 +0200
commita492094373ef5fd9ed9f2a1329248ee293ae880a (patch)
tree7565aec4faaa9f3a7ed863c2830a960db07a1fda /src/script/bridge/qscriptqobject.cpp
parentf49ad8b7c74f37c580b5af9584a9f576df831e06 (diff)
Update implementation of callQtMethod after QMetaType::UnknownType introduction
This patch gets rid of qWarning caused by misuse of QVariant. Change-Id: I889bd3830d86ea6d69db7a7ddb160a1f4da0c9bd Reviewed-by: Kent Hansen <kent.hansen@nokia.com> Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
Diffstat (limited to 'src/script/bridge/qscriptqobject.cpp')
-rw-r--r--src/script/bridge/qscriptqobject.cpp18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/script/bridge/qscriptqobject.cpp b/src/script/bridge/qscriptqobject.cpp
index 7aa3e5a..7353757 100644
--- a/src/script/bridge/qscriptqobject.cpp
+++ b/src/script/bridge/qscriptqobject.cpp
@@ -394,8 +394,8 @@ private:
int QScriptMetaType::typeId() const
{
if (isVariant())
- return QMetaType::type("QVariant");
- return isMetaEnum() ? 2/*int*/ : m_typeId;
+ return QMetaType::QVariant;
+ return isMetaEnum() ? QMetaType::Int : m_typeId;
}
QByteArray QScriptMetaType::name() const
@@ -520,8 +520,8 @@ static JSC::JSValue callQtMethod(JSC::ExecState *exec, QMetaMethod::MethodType c
QScriptMetaType *typesData = types.data();
// resolve return type
QByteArray returnTypeName = method.typeName();
- int rtype = QMetaType::type(returnTypeName);
- if ((rtype == 0) && !returnTypeName.isEmpty()) {
+ int rtype = method.returnType();
+ if ((rtype == QMetaType::UnknownType) && !returnTypeName.isEmpty()) {
int enumIndex = indexOfMetaEnum(meta, returnTypeName);
if (enumIndex != -1)
typesData[0] = QScriptMetaType::metaEnum(enumIndex, returnTypeName);
@@ -540,7 +540,7 @@ static JSC::JSValue callQtMethod(JSC::ExecState *exec, QMetaMethod::MethodType c
for (int i = 0; i < parameterTypeNames.count(); ++i) {
QByteArray argTypeName = parameterTypeNames.at(i);
int atype = QMetaType::type(argTypeName);
- if (atype == 0) {
+ if (atype == QMetaType::UnknownType) {
int enumIndex = indexOfMetaEnum(meta, argTypeName);
if (enumIndex != -1)
typesData[1 + i] = QScriptMetaType::metaEnum(enumIndex, argTypeName);
@@ -571,8 +571,10 @@ static JSC::JSValue callQtMethod(JSC::ExecState *exec, QMetaMethod::MethodType c
if (args.count() != mtd.count())
args.resize(mtd.count());
- QScriptMetaType retType = mtd.returnType();
- args[0] = QVariant(retType.typeId(), (void *)0); // the result
+ if (rtype != QMetaType::Void) {
+ // initialize the result
+ args[0] = QVariant(rtype, (void *)0);
+ }
// try to convert arguments
bool converted = true;
@@ -943,7 +945,7 @@ static JSC::JSValue callQtMethod(JSC::ExecState *exec, QMetaMethod::MethodType c
QScriptMetaType retType = chosenMethod.returnType();
if (retType.isVariant()) {
result = QScriptEnginePrivate::jscValueFromVariant(exec, *(QVariant *)params[0]);
- } else if (retType.typeId() != 0) {
+ } else if (retType.typeId() != QMetaType::Void) {
result = QScriptEnginePrivate::create(exec, retType.typeId(), params[0]);
if (!result)
result = engine->newVariant(QVariant(retType.typeId(), params[0]));