From 0460d63ed03f0de574a06268df2a267d44784cb0 Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Mon, 9 Jan 2012 08:56:34 +0100 Subject: Fix JS to QVariant type conversion MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1) The special case for LastType (QVariant) should be done before the general conversion, to avoid calling convertValue() with targetType == -1 (which is useless and causes a qWarning). 2) moc is about to be changed to use QMetaType::QVariant instead of QVariant::LastType to represent the QVariant type. But to keep the CI happy in the transition period we have to check for both. The LastType check will be removed once qtbase has been updated. 3) Get rid of the variantFromValue function in qscriptqobject. It was identical to QScriptEnginePrivate::jscValueToVariant. Change-Id: Ie418facc06c6c7308bc60a3ff66b9a78b109d3d3 Reviewed-by: Jędrzej Nowacki Reviewed-by: Friedemann Kleint --- src/script/api/qscriptengine.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/script/api/qscriptengine.cpp') diff --git a/src/script/api/qscriptengine.cpp b/src/script/api/qscriptengine.cpp index 3783602..e3bfc61 100644 --- a/src/script/api/qscriptengine.cpp +++ b/src/script/api/qscriptengine.cpp @@ -1041,11 +1041,11 @@ QScriptEnginePrivate::~QScriptEnginePrivate() QVariant QScriptEnginePrivate::jscValueToVariant(JSC::ExecState *exec, JSC::JSValue value, int targetType) { + if (targetType == QMetaType::QVariant || uint(targetType) == QVariant::LastType) + return toVariant(exec, value); QVariant v(targetType, (void *)0); if (convertValue(exec, value, targetType, v.data())) return v; - if (uint(targetType) == QVariant::LastType) - return toVariant(exec, value); if (isVariant(value)) { v = variantValue(value); if (v.canConvert(QVariant::Type(targetType))) { -- cgit v1.2.3