aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@digia.com>2013-12-06 10:51:42 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-12-24 10:32:35 +0100
commit70004585f89f325f398c556d101bfa1833d87b53 (patch)
tree050bd5a01a2c2ce61f756b13860da93302d7f317
parent13e88fe2b9b1680cb161a249289c3ba998f08c0c (diff)
Change C++ parameter type used for var parameters in QML declared signals
"signal someSignal(var foo)" mapped to foo being of type QVariant. Unfortunately that is a "lossy" type and it cannot represent all JavaScript values, including for example function closures (as reported in the JIRA bug). Instead we should use QJSValue. It is an important behavioural change because it affects the presumably rare case of somebody declaring a signal in QML with such a parameter and connect to it from C++ (or trying to emit it) - in that situation the code needs to be changed. Task-number: QTBUG-35171 Change-Id: I4fb4a18b407e4ea6c28a3a297fc6f76edb76d734 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
-rw-r--r--dist/changes-5.3.068
-rw-r--r--src/qml/qml/qqmlcompiler.cpp2
-rw-r--r--src/qml/qml/qqmlobjectcreator.cpp2
-rw-r--r--tests/auto/qml/qqmlecmascript/data/signalHandlers.qml11
-rw-r--r--tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp3
-rw-r--r--tests/auto/qml/qqmlmetaobject/tst_qqmlmetaobject.cpp6
6 files changed, 87 insertions, 5 deletions
diff --git a/dist/changes-5.3.0 b/dist/changes-5.3.0
new file mode 100644
index 0000000000..5cda809d97
--- /dev/null
+++ b/dist/changes-5.3.0
@@ -0,0 +1,68 @@
+Qt 5.3 introduces many new features and improvements as well as bugfixes
+over the 5.2.x series. For more details, refer to the online documentation
+included in this distribution. The documentation is also available online:
+
+ http://qt-project.org/doc/qt-5.2
+
+The Qt version 5.3 series is binary compatible with the 5.2.x series.
+Applications compiled for 5.2 will continue to run with 5.3.
+
+Some of the changes listed in this file include issue tracking numbers
+corresponding to tasks in the Qt Bug Tracker:
+
+ http://bugreports.qt-project.org/
+
+Each of these identifiers can be entered in the bug tracker to obtain more
+information about a particular change.
+
+****************************************************************************
+* General *
+****************************************************************************
+
+General Improvements
+--------------------
+
+Third party components
+----------------------
+
+****************************************************************************
+* Important Behavior Changes *
+****************************************************************************
+
+- Signals declared in QML that take "var" parameters, are now using QJSValue
+ as C++ type for these parameters, instead of QVariant.
+
+****************************************************************************
+* Library *
+****************************************************************************
+
+QtQml
+------
+
+QtQuick
+------
+
+****************************************************************************
+* Database Drivers *
+****************************************************************************
+
+
+****************************************************************************
+* Platform Specific Changes *
+****************************************************************************
+
+
+****************************************************************************
+* Compiler Specific Changes *
+****************************************************************************
+
+
+****************************************************************************
+* Tools *
+****************************************************************************
+
+
+****************************************************************************
+* Plugins *
+****************************************************************************
+
diff --git a/src/qml/qml/qqmlcompiler.cpp b/src/qml/qml/qqmlcompiler.cpp
index 2e208f2f3b..f07d4bb703 100644
--- a/src/qml/qml/qqmlcompiler.cpp
+++ b/src/qml/qml/qqmlcompiler.cpp
@@ -2882,7 +2882,7 @@ bool QQmlCompiler::buildDynamicMeta(QQmlScript::Object *obj, DynamicMetaMode mod
Object::DynamicProperty::Type dtype;
int metaType;
} builtinTypes[] = {
- { Object::DynamicProperty::Var, QMetaType::QVariant },
+ { Object::DynamicProperty::Var, qMetaTypeId<QJSValue>() },
{ Object::DynamicProperty::Variant, QMetaType::QVariant },
{ Object::DynamicProperty::Int, QMetaType::Int },
{ Object::DynamicProperty::Bool, QMetaType::Bool },
diff --git a/src/qml/qml/qqmlobjectcreator.cpp b/src/qml/qml/qqmlobjectcreator.cpp
index 3798129e8b..81862a1429 100644
--- a/src/qml/qml/qqmlobjectcreator.cpp
+++ b/src/qml/qml/qqmlobjectcreator.cpp
@@ -128,7 +128,7 @@ bool QQmlPropertyCacheCreator::create(const QV4::CompiledData::Object *obj, QQml
QV4::CompiledData::Property::Type dtype;
int metaType;
} builtinTypes[] = {
- { QV4::CompiledData::Property::Var, QMetaType::QVariant },
+ { QV4::CompiledData::Property::Var, qMetaTypeId<QJSValue>() },
{ QV4::CompiledData::Property::Variant, QMetaType::QVariant },
{ QV4::CompiledData::Property::Int, QMetaType::Int },
{ QV4::CompiledData::Property::Bool, QMetaType::Bool },
diff --git a/tests/auto/qml/qqmlecmascript/data/signalHandlers.qml b/tests/auto/qml/qqmlecmascript/data/signalHandlers.qml
index 7e85312692..cd68fb9b82 100644
--- a/tests/auto/qml/qqmlecmascript/data/signalHandlers.qml
+++ b/tests/auto/qml/qqmlecmascript/data/signalHandlers.qml
@@ -91,4 +91,15 @@ QtObject {
testObjectWithAliasHandler.count++
return testObjectWithAliasHandler.testSuccess
}
+
+ signal signalWithClosureArgument(var f)
+ onSignalWithClosureArgument: f()
+
+ function testSignalWithClosureArgument() {
+ var testSuccess = false
+ signalWithClosureArgument(function() {
+ testSuccess = true
+ })
+ return testSuccess
+ }
}
diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
index 7b89709923..d06266a360 100644
--- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
+++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
@@ -6068,6 +6068,9 @@ void tst_qqmlecmascript::signalHandlers()
QMetaObject::invokeMethod(o, "testAliasSignalHandler", Q_RETURN_ARG(QVariant, result));
QCOMPARE(result.toBool(), true);
+ QMetaObject::invokeMethod(o, "testSignalWithClosureArgument", Q_RETURN_ARG(QVariant, result));
+ QCOMPARE(result.toBool(), true);
+
delete o;
}
diff --git a/tests/auto/qml/qqmlmetaobject/tst_qqmlmetaobject.cpp b/tests/auto/qml/qqmlmetaobject/tst_qqmlmetaobject.cpp
index b1f83fcd6c..b0c7c5e81a 100644
--- a/tests/auto/qml/qqmlmetaobject/tst_qqmlmetaobject.cpp
+++ b/tests/auto/qml/qqmlmetaobject/tst_qqmlmetaobject.cpp
@@ -329,11 +329,11 @@ void tst_QQmlMetaObject::method_data()
<< (QList<QByteArray>() << "int" << "bool" << "double")
<< (QList<QByteArray>() << "foo" << "bar" << "baz");
QTest::newRow("testSignal(variant foo, var bar)") << "signal.4.qml"
- << "testSignal(QVariant,QVariant)"
+ << "testSignal(QVariant,QJSValue)"
<< QMetaMethod::Signal
<< int(QMetaType::Void) << "void"
- << (QList<int>() << QMetaType::QVariant << QMetaType::QVariant)
- << (QList<QByteArray>() << "QVariant" << "QVariant")
+ << (QList<int>() << QMetaType::QVariant << qMetaTypeId<QJSValue>())
+ << (QList<QByteArray>() << "QVariant" << "QJSValue")
<< (QList<QByteArray>() << "foo" << "bar");
QTest::newRow("testSignal(color foo, date bar, url baz)") << "signal.5.qml"
<< "testSignal(QColor,QDateTime,QUrl)"