From 6a02fb09af8dce6ca533e816d2223e070b30f294 Mon Sep 17 00:00:00 2001 From: Robin Burchell Date: Tue, 16 May 2017 19:08:28 +0200 Subject: QQmlIRBuilder: Only query type name cache for type names The behavior here was always incorrect: type names must start with an uppercase letter, so querying the type name cache with a lowercase string is wrong. However, this was turned into a larger problem by making more extensive use of QQmlTypeNameCache in e74a1d0b342f2c95dc3a543c8c9ec07fd52d8fe0, as it contained a lot of new types (including composite types, which previously were only in the cache if they were singletons). Task-number: QTBUG-60547 Change-Id: I40be2d535e99d3e1af250d995d7149ecbe2965d7 Reviewed-by: Simon Hausmann --- tests/auto/qml/qqmlecmascript/data/qtbug60547/TestObject.qml | 11 +++++++++++ .../qml/qqmlecmascript/data/qtbug60547/components/Counter.qml | 4 ++++ tests/auto/qml/qqmlecmascript/data/qtbug60547/main.qml | 8 ++++++++ tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp | 11 +++++++++++ 4 files changed, 34 insertions(+) create mode 100644 tests/auto/qml/qqmlecmascript/data/qtbug60547/TestObject.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/qtbug60547/components/Counter.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/qtbug60547/main.qml (limited to 'tests') diff --git a/tests/auto/qml/qqmlecmascript/data/qtbug60547/TestObject.qml b/tests/auto/qml/qqmlecmascript/data/qtbug60547/TestObject.qml new file mode 100644 index 0000000000..5f022f605a --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/qtbug60547/TestObject.qml @@ -0,0 +1,11 @@ +import QtQuick 2.0 +import "components" + +QtObject { + id: root + property int counter + function increment() { + counter++ + return counter + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/qtbug60547/components/Counter.qml b/tests/auto/qml/qqmlecmascript/data/qtbug60547/components/Counter.qml new file mode 100644 index 0000000000..3c5e65a340 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/qtbug60547/components/Counter.qml @@ -0,0 +1,4 @@ +import QtQuick 2.0 + +QtObject {} + diff --git a/tests/auto/qml/qqmlecmascript/data/qtbug60547/main.qml b/tests/auto/qml/qqmlecmascript/data/qtbug60547/main.qml new file mode 100644 index 0000000000..b09366e9df --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/qtbug60547/main.qml @@ -0,0 +1,8 @@ +import QtQml 2.0 + +TestObject { + Component.onCompleted: { + increment() + } +} + diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp index 72179d243f..7b9a43dc38 100644 --- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp +++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp @@ -337,6 +337,7 @@ private slots: void instanceof(); void freeze_empty_object(); void singleBlockLoops(); + void qtbug_60547(); private: // static void propertyVarWeakRefCallback(v8::Persistent object, void* parameter); @@ -8250,6 +8251,16 @@ void tst_qqmlecmascript::singleBlockLoops() QVERIFY(!component.isError()); } +// 'counter' was incorrectly resolved as a type rather than a variable. +// This fix ensures it looks up the right thing. +void tst_qqmlecmascript::qtbug_60547() +{ + QQmlComponent component(&engine, testFileUrl("qtbug60547/main.qml")); + QScopedPointer object(component.create()); + QVERIFY2(!object.isNull(), qPrintable(component.errorString())); + QCOMPARE(object->property("counter"), QVariant(int(1))); +} + QTEST_MAIN(tst_qqmlecmascript) #include "tst_qqmlecmascript.moc" -- cgit v1.2.3 From 5f49b2b3bb30678a26341e1f45e0cfd6a6fd2c57 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Thu, 11 May 2017 17:19:14 +0200 Subject: QML Settings: fix JS array handling Before Qt 5.4, JS arrays were passed as QVariantLists. Since Qt 5.4, they are passed as QJSValues instead. Use QJSValue::toVariant() (the same way as QQuickItemView::setModel(QVariant) which was fixed in cf959b4b) to convert JS values to QSettings-compatible variants. Task-number: QTBUG-45316 Change-Id: Icc6f8ad09bfef089d9efcf5b90e3783bb3f73a9f Reviewed-by: Simon Hausmann --- tests/auto/qml/qqmlsettings/data/aliases.qml | 4 + tests/auto/qml/qqmlsettings/data/cpp-aliases.qml | 2 + tests/auto/qml/qqmlsettings/data/types.qml | 6 + tests/auto/qml/qqmlsettings/tst_qqmlsettings.cpp | 206 ++++++----------------- 4 files changed, 65 insertions(+), 153 deletions(-) (limited to 'tests') diff --git a/tests/auto/qml/qqmlsettings/data/aliases.qml b/tests/auto/qml/qqmlsettings/data/aliases.qml index 18bd7a0e07..dd11147532 100644 --- a/tests/auto/qml/qqmlsettings/data/aliases.qml +++ b/tests/auto/qml/qqmlsettings/data/aliases.qml @@ -38,8 +38,10 @@ QtObject { property double doubleProperty: 3.45 property string stringProperty: "foo" property url urlProperty: "http://www.qt-project.org" + property var objectProperty: {"foo":"bar"} property var intListProperty: [1, 2, 3] property var stringListProperty: ["a", "b", "c"] + property var objectListProperty: [{"a":"b"}, {"c":"d"}] property date dateProperty: "2000-01-02" // QTBUG-32295: Expected property type //property time timeProperty: "12:34:56" @@ -58,8 +60,10 @@ QtObject { property alias doubleProperty: root.doubleProperty property alias stringProperty: root.stringProperty property alias urlProperty: root.urlProperty + property alias objectProperty: root.objectProperty property alias intListProperty: root.intListProperty property alias stringListProperty: root.stringListProperty + property alias objectListProperty: root.objectListProperty property alias dateProperty: root.dateProperty // QTBUG-32295: Expected property type //property alias timeProperty: root.timeProperty diff --git a/tests/auto/qml/qqmlsettings/data/cpp-aliases.qml b/tests/auto/qml/qqmlsettings/data/cpp-aliases.qml index 8540838fb9..f5b18d1825 100644 --- a/tests/auto/qml/qqmlsettings/data/cpp-aliases.qml +++ b/tests/auto/qml/qqmlsettings/data/cpp-aliases.qml @@ -40,8 +40,10 @@ CppObject { property alias doubleProperty: obj.doubleProperty property alias stringProperty: obj.stringProperty property alias urlProperty: obj.urlProperty + property alias objectProperty: obj.objectProperty property alias intListProperty: obj.intListProperty property alias stringListProperty: obj.stringListProperty + property alias objectListProperty: obj.objectListProperty property alias dateProperty: obj.dateProperty // QTBUG-32295: Expected property type //property alias timeProperty: obj.timeProperty diff --git a/tests/auto/qml/qqmlsettings/data/types.qml b/tests/auto/qml/qqmlsettings/data/types.qml index d1301af057..c4efa0be7c 100644 --- a/tests/auto/qml/qqmlsettings/data/types.qml +++ b/tests/auto/qml/qqmlsettings/data/types.qml @@ -38,8 +38,10 @@ QtObject { property double doubleProperty property string stringProperty property url urlProperty + property var objectProperty property var intListProperty property var stringListProperty + property var objectListProperty property date dateProperty // QTBUG-32295: Expected property type // property time timeProperty @@ -64,8 +66,10 @@ QtObject { to.doubleProperty = from.doubleProperty to.stringProperty = from.stringProperty to.urlProperty = from.urlProperty + to.objectProperty = from.objectProperty to.intListProperty = from.intListProperty to.stringListProperty = from.stringListProperty + to.objectListProperty = from.objectListProperty to.dateProperty = from.dateProperty //to.timeProperty = from.timeProperty to.sizeProperty = from.sizeProperty @@ -84,8 +88,10 @@ QtObject { property double doubleProperty: 3.45 property string stringProperty: "foo" property url urlProperty: "http://www.qt-project.org" + property var objectProperty: {"foo":"bar"} property var intListProperty: [1, 2, 3] property var stringListProperty: ["a", "b", "c"] + property var objectListProperty: [{"a":"b"}, {"c":"d"}] property date dateProperty: "2000-01-02" // QTBUG-32295: Expected property type //property time timeProperty: "12:34:56" diff --git a/tests/auto/qml/qqmlsettings/tst_qqmlsettings.cpp b/tests/auto/qml/qqmlsettings/tst_qqmlsettings.cpp index c2e20f8892..e08389045c 100644 --- a/tests/auto/qml/qqmlsettings/tst_qqmlsettings.cpp +++ b/tests/auto/qml/qqmlsettings/tst_qqmlsettings.cpp @@ -55,25 +55,36 @@ private slots: void initial(); }; +// ### Replace keyValueMap("foo", "bar") with QVariantMap({{"foo", "bar"}}) +// when C++11 uniform initialization can be used (not supported by MSVC 2013). +static QVariantMap keyValueMap(const QString &key, const QString &value) +{ + QVariantMap var; + var.insert(key, value); + return var; +} + class CppObject : public QObject { Q_OBJECT - Q_PROPERTY(int intProperty READ intProperty WRITE setIntProperty NOTIFY intPropertyChanged) - Q_PROPERTY(bool boolProperty READ boolProperty WRITE setBoolProperty NOTIFY boolPropertyChanged) - Q_PROPERTY(qreal realProperty READ realProperty WRITE setRealProperty NOTIFY realPropertyChanged) - Q_PROPERTY(double doubleProperty READ doubleProperty WRITE setDoubleProperty NOTIFY doublePropertyChanged) - Q_PROPERTY(QString stringProperty READ stringProperty WRITE setStringProperty NOTIFY stringPropertyChanged) - Q_PROPERTY(QUrl urlProperty READ urlProperty WRITE setUrlProperty NOTIFY urlPropertyChanged) - Q_PROPERTY(QVariant varProperty READ varProperty WRITE setVarProperty NOTIFY varPropertyChanged) - Q_PROPERTY(QVariantList intListProperty READ intListProperty WRITE setIntListProperty NOTIFY intListPropertyChanged) - Q_PROPERTY(QVariantList stringListProperty READ stringListProperty WRITE setStringListProperty NOTIFY stringListPropertyChanged) - Q_PROPERTY(QDate dateProperty READ dateProperty WRITE setDateProperty NOTIFY datePropertyChanged) - // QTBUG-32295: Q_PROPERTY(QTime timeProperty READ timeProperty WRITE setTimeProperty NOTIFY timePropertyChanged) - Q_PROPERTY(QSizeF sizeProperty READ sizeProperty WRITE setSizeProperty NOTIFY sizePropertyChanged) - Q_PROPERTY(QPointF pointProperty READ pointProperty WRITE setPointProperty NOTIFY pointPropertyChanged) - Q_PROPERTY(QRectF rectProperty READ rectProperty WRITE setRectProperty NOTIFY rectPropertyChanged) - Q_PROPERTY(QColor colorProperty READ colorProperty WRITE setColorProperty NOTIFY colorPropertyChanged) - Q_PROPERTY(QFont fontProperty READ fontProperty WRITE setFontProperty NOTIFY fontPropertyChanged) + Q_PROPERTY(int intProperty MEMBER m_intProperty NOTIFY intPropertyChanged) + Q_PROPERTY(bool boolProperty MEMBER m_boolProperty NOTIFY boolPropertyChanged) + Q_PROPERTY(qreal realProperty MEMBER m_realProperty NOTIFY realPropertyChanged) + Q_PROPERTY(double doubleProperty MEMBER m_doubleProperty NOTIFY doublePropertyChanged) + Q_PROPERTY(QString stringProperty MEMBER m_stringProperty NOTIFY stringPropertyChanged) + Q_PROPERTY(QUrl urlProperty MEMBER m_urlProperty NOTIFY urlPropertyChanged) + Q_PROPERTY(QVariant varProperty MEMBER m_varProperty NOTIFY varPropertyChanged) + Q_PROPERTY(QVariantMap objectProperty MEMBER m_objectProperty NOTIFY objectPropertyChanged) + Q_PROPERTY(QVariantList intListProperty MEMBER m_intListProperty NOTIFY intListPropertyChanged) + Q_PROPERTY(QVariantList stringListProperty MEMBER m_stringListProperty NOTIFY stringListPropertyChanged) + Q_PROPERTY(QVariantList objectListProperty MEMBER m_objectListProperty NOTIFY objectListPropertyChanged) + Q_PROPERTY(QDate dateProperty MEMBER m_dateProperty NOTIFY datePropertyChanged) + // QTBUG-32295: Q_PROPERTY(QTime timeProperty MEMBER m_timeProperty NOTIFY timePropertyChanged) + Q_PROPERTY(QSizeF sizeProperty MEMBER m_sizeProperty NOTIFY sizePropertyChanged) + Q_PROPERTY(QPointF pointProperty MEMBER m_pointProperty NOTIFY pointPropertyChanged) + Q_PROPERTY(QRectF rectProperty MEMBER m_rectProperty NOTIFY rectPropertyChanged) + Q_PROPERTY(QColor colorProperty MEMBER m_colorProperty NOTIFY colorPropertyChanged) + Q_PROPERTY(QFont fontProperty MEMBER m_fontProperty NOTIFY fontPropertyChanged) public: CppObject(QObject *parent = 0) : QObject(parent), @@ -83,8 +94,10 @@ public: m_doubleProperty(3.45), m_stringProperty("foo"), m_urlProperty("http://www.qt-project.org"), + m_objectProperty(keyValueMap("foo", "bar")), m_intListProperty(QVariantList() << 1 << 2 << 3), m_stringListProperty(QVariantList() << "a" << "b" << "c"), + m_objectListProperty(QVariantList() << keyValueMap("a", "b") << keyValueMap("c", "d")), m_dateProperty(2000, 1, 2), // QTBUG-32295: m_timeProperty(12, 34, 56), m_sizeProperty(12, 34), @@ -94,143 +107,6 @@ public: { } - int intProperty() const { return m_intProperty; } - bool boolProperty() const { return m_boolProperty; } - qreal realProperty() const { return m_realProperty; } - double doubleProperty() const { return m_doubleProperty; } - QString stringProperty() const { return m_stringProperty; } - QUrl urlProperty() const { return m_urlProperty; } - QVariant varProperty() const { return m_varProperty; } - QVariantList intListProperty() const { return m_intListProperty; } - QVariantList stringListProperty() const { return m_stringListProperty; } - QDate dateProperty() const { return m_dateProperty; } - QSizeF sizeProperty() const { return m_sizeProperty; } - QPointF pointProperty() const { return m_pointProperty; } - QRectF rectProperty() const { return m_rectProperty; } - QColor colorProperty() const { return m_colorProperty; } - QFont fontProperty() const { return m_fontProperty; } - -public slots: - void setIntProperty(int arg) - { - if (m_intProperty != arg) { - m_intProperty = arg; - emit intPropertyChanged(arg); - } - } - - void setBoolProperty(bool arg) - { - if (m_boolProperty != arg) { - m_boolProperty = arg; - emit boolPropertyChanged(arg); - } - } - - void setRealProperty(qreal arg) - { - if (m_realProperty != arg) { - m_realProperty = arg; - emit realPropertyChanged(arg); - } - } - - void setDoubleProperty(double arg) - { - if (m_doubleProperty != arg) { - m_doubleProperty = arg; - emit doublePropertyChanged(arg); - } - } - - void setStringProperty(const QString &arg) - { - if (m_stringProperty != arg) { - m_stringProperty = arg; - emit stringPropertyChanged(arg); - } - } - - void setUrlProperty(const QUrl &arg) - { - if (m_urlProperty != arg) { - m_urlProperty = arg; - emit urlPropertyChanged(arg); - } - } - - void setVarProperty(const QVariant &arg) - { - if (m_varProperty != arg) { - m_varProperty = arg; - emit varPropertyChanged(arg); - } - } - - void setIntListProperty(const QVariantList &arg) - { - if (m_intListProperty != arg) { - m_intListProperty = arg; - emit intListPropertyChanged(arg); - } - } - - void setStringListProperty(const QVariantList &arg) - { - if (m_stringListProperty != arg) { - m_stringListProperty = arg; - emit stringListPropertyChanged(arg); - } - } - - void setDateProperty(const QDate &arg) - { - if (m_dateProperty != arg) { - m_dateProperty = arg; - emit datePropertyChanged(arg); - } - } - - void setSizeProperty(const QSizeF &arg) - { - if (m_sizeProperty != arg) { - m_sizeProperty = arg; - emit sizePropertyChanged(arg); - } - } - - void setPointProperty(const QPointF &arg) - { - if (m_pointProperty != arg) { - m_pointProperty = arg; - emit pointPropertyChanged(arg); - } - } - - void setRectProperty(const QRectF &arg) - { - if (m_rectProperty != arg) { - m_rectProperty = arg; - emit rectPropertyChanged(arg); - } - } - - void setColorProperty(const QColor &arg) - { - if (m_colorProperty != arg) { - m_colorProperty = arg; - emit colorPropertyChanged(arg); - } - } - - void setFontProperty(const QFont &arg) - { - if (m_fontProperty != arg) { - m_fontProperty = arg; - emit fontPropertyChanged(arg); - } - } - signals: void intPropertyChanged(int arg); void boolPropertyChanged(bool arg); @@ -239,8 +115,10 @@ signals: void stringPropertyChanged(const QString &arg); void urlPropertyChanged(const QUrl &arg); void varPropertyChanged(const QVariant &arg); + void objectPropertyChanged(const QVariantMap &arg); void intListPropertyChanged(const QVariantList &arg); void stringListPropertyChanged(const QVariantList &arg); + void objectListPropertyChanged(const QVariantList &arg); void datePropertyChanged(const QDate &arg); void sizePropertyChanged(const QSizeF &arg); void pointPropertyChanged(const QPointF &arg); @@ -256,8 +134,10 @@ private: QString m_stringProperty; QUrl m_urlProperty; QVariant m_varProperty; + QVariantMap m_objectProperty; QVariantList m_intListProperty; QVariantList m_stringListProperty; + QVariantList m_objectListProperty; QDate m_dateProperty; QSizeF m_sizeProperty; QPointF m_pointProperty; @@ -316,8 +196,10 @@ void tst_QQmlSettings::types() QCOMPARE(root->property("doubleProperty").toDouble(), static_cast(0.0)); QCOMPARE(root->property("stringProperty").toString(), QString()); QCOMPARE(root->property("urlProperty").toUrl(), QUrl()); + QCOMPARE(root->property("objectProperty").toMap(), QVariantMap()); QCOMPARE(root->property("intListProperty").toList(), QVariantList()); QCOMPARE(root->property("stringListProperty").toList(), QVariantList()); + QCOMPARE(root->property("objectListProperty").toList(), QVariantList()); QCOMPARE(root->property("dateProperty").toDate(), QDate()); // QTBUG-32295: QCOMPARE(root->property("timeProperty").toDate(), QTime()); QCOMPARE(root->property("sizeProperty").toSizeF(), QSizeF()); @@ -333,8 +215,10 @@ void tst_QQmlSettings::types() QCOMPARE(settings->property("doubleProperty").toDouble(), static_cast(3.45)); QCOMPARE(settings->property("stringProperty").toString(), QStringLiteral("foo")); QCOMPARE(settings->property("urlProperty").toUrl(), QUrl("http://www.qt-project.org")); + QCOMPARE(settings->property("objectProperty").toMap(), keyValueMap("foo","bar")); QCOMPARE(settings->property("intListProperty").toList(), QVariantList() << 1 << 2 << 3); QCOMPARE(settings->property("stringListProperty").toList(), QVariantList() << QStringLiteral("a") << QStringLiteral("b") << QStringLiteral("c")); + QCOMPARE(settings->property("objectListProperty").toList(), QVariantList() << keyValueMap("a", "b") << keyValueMap("c","d")); QCOMPARE(settings->property("dateProperty").toDate(), QDate(2000, 01, 02)); // QTBUG-32295: QCOMPARE(settings->property("timeProperty").toDate(), QTime(12, 34, 56)); QCOMPARE(settings->property("sizeProperty").toSizeF(), QSizeF(12, 34)); @@ -351,9 +235,11 @@ void tst_QQmlSettings::types() QCOMPARE(root->property("doubleProperty").toDouble(), static_cast(3.45)); QCOMPARE(root->property("stringProperty").toString(), QStringLiteral("foo")); QCOMPARE(root->property("urlProperty").toUrl(), QUrl("http://www.qt-project.org")); + QCOMPARE(root->property("objectProperty").toMap(), keyValueMap("foo","bar")); QCOMPARE(root->property("intListProperty").toList(), QVariantList() << 1 << 2 << 3); QCOMPARE(root->property("stringListProperty").toList(), QVariantList() << QStringLiteral("a") << QStringLiteral("b") << QStringLiteral("c")); QCOMPARE(root->property("dateProperty").toDate(), QDate(2000, 01, 02)); + QCOMPARE(root->property("objectListProperty").toList(), QVariantList() << keyValueMap("a", "b") << keyValueMap("c","d")); // QTBUG-32295: QCOMPARE(root->property("timeProperty").toDate(), QTime(12, 34, 56)); QCOMPARE(root->property("sizeProperty").toSizeF(), QSizeF(12, 34)); QCOMPARE(root->property("pointProperty").toPointF(), QPointF(12, 34)); @@ -368,8 +254,10 @@ void tst_QQmlSettings::types() QVERIFY(root->setProperty("doubleProperty", static_cast(6.78))); QVERIFY(root->setProperty("stringProperty", QStringLiteral("bar"))); QVERIFY(root->setProperty("urlProperty", QUrl("https://codereview.qt-project.org"))); + QVERIFY(root->setProperty("objectProperty", keyValueMap("bar", "baz"))); QVERIFY(root->setProperty("intListProperty", QVariantList() << 4 << 5 << 6)); QVERIFY(root->setProperty("stringListProperty", QVariantList() << QStringLiteral("d") << QStringLiteral("e") << QStringLiteral("f"))); + QVERIFY(root->setProperty("objectListProperty", QVariantList() << keyValueMap("e", "f") << keyValueMap("g", "h"))); QVERIFY(root->setProperty("dateProperty", QDate(2010, 02, 01))); // QTBUG-32295: QVERIFY(root->setProperty("timeProperty", QTime(6, 56, 34))); QVERIFY(root->setProperty("sizeProperty", QSizeF(56, 78))); @@ -387,8 +275,10 @@ void tst_QQmlSettings::types() QTRY_COMPARE(settings->property("doubleProperty").toDouble(), static_cast(6.78)); QTRY_COMPARE(settings->property("stringProperty").toString(), QStringLiteral("bar")); QTRY_COMPARE(settings->property("urlProperty").toUrl(), QUrl("https://codereview.qt-project.org")); + QTRY_COMPARE(settings->property("objectProperty").toMap(), keyValueMap("bar", "baz")); QTRY_COMPARE(settings->property("intListProperty").toList(), QVariantList() << 4 << 5 << 6); QTRY_COMPARE(settings->property("stringListProperty").toList(), QVariantList() << QStringLiteral("d") << QStringLiteral("e") << QStringLiteral("f")); + QTRY_COMPARE(settings->property("objectListProperty").toList(), QVariantList() << keyValueMap("e", "f") << keyValueMap("g", "h")); QTRY_COMPARE(settings->property("dateProperty").toDate(), QDate(2010, 02, 01)); // QTBUG-32295: QTRY_COMPARE(settings->property("timeProperty").toDate(), QTime(6, 56, 34)); QTRY_COMPARE(settings->property("sizeProperty").toSizeF(), QSizeF(56, 78)); @@ -404,8 +294,10 @@ void tst_QQmlSettings::types() QTRY_COMPARE(qs.value("doubleProperty").toDouble(), static_cast(6.78)); QTRY_COMPARE(qs.value("stringProperty").toString(), QStringLiteral("bar")); QTRY_COMPARE(qs.value("urlProperty").toUrl(), QUrl("https://codereview.qt-project.org")); + QTRY_COMPARE(qs.value("objectProperty").toMap(), keyValueMap("bar", "baz")); QTRY_COMPARE(qs.value("intListProperty").toList(), QVariantList() << 4 << 5 << 6); QTRY_COMPARE(qs.value("stringListProperty").toList(), QVariantList() << QStringLiteral("d") << QStringLiteral("e") << QStringLiteral("f")); + QTRY_COMPARE(qs.value("objectListProperty").toList(), QVariantList() << keyValueMap("e", "f") << keyValueMap("g", "h")); QTRY_COMPARE(qs.value("dateProperty").toDate(), QDate(2010, 02, 01)); // QTBUG-32295: QTRY_COMPARE(qs.value("timeProperty").toDate(), QTime(6, 56, 34)); QTRY_COMPARE(qs.value("sizeProperty").toSizeF(), QSizeF(56, 78)); @@ -440,8 +332,10 @@ void tst_QQmlSettings::aliases() QCOMPARE(root->property("doubleProperty").toDouble(), static_cast(3.45)); QCOMPARE(root->property("stringProperty").toString(), QStringLiteral("foo")); QCOMPARE(root->property("urlProperty").toUrl(), QUrl("http://www.qt-project.org")); + QCOMPARE(root->property("objectProperty").toMap(), keyValueMap("foo","bar")); QCOMPARE(root->property("intListProperty").toList(), QVariantList() << 1 << 2 << 3); QCOMPARE(root->property("stringListProperty").toList(), QVariantList() << QStringLiteral("a") << QStringLiteral("b") << QStringLiteral("c")); + QCOMPARE(root->property("objectListProperty").toList(), QVariantList() << keyValueMap("a", "b") << keyValueMap("c","d")); QCOMPARE(root->property("dateProperty").toDate(), QDate(2000, 01, 02)); // QTBUG-32295: QCOMPARE(root->property("timeProperty").toDate(), QTime(12, 34, 56)); QCOMPARE(root->property("sizeProperty").toSizeF(), QSizeF(12, 34)); @@ -457,8 +351,10 @@ void tst_QQmlSettings::aliases() QCOMPARE(settings->property("doubleProperty").toDouble(), static_cast(3.45)); QCOMPARE(settings->property("stringProperty").toString(), QStringLiteral("foo")); QCOMPARE(settings->property("urlProperty").toUrl(), QUrl("http://www.qt-project.org")); + QCOMPARE(settings->property("objectProperty").toMap(), keyValueMap("foo","bar")); QCOMPARE(settings->property("intListProperty").toList(), QVariantList() << 1 << 2 << 3); QCOMPARE(settings->property("stringListProperty").toList(), QVariantList() << QStringLiteral("a") << QStringLiteral("b") << QStringLiteral("c")); + QCOMPARE(settings->property("objectListProperty").toList(), QVariantList() << keyValueMap("a", "b") << keyValueMap("c","d")); QCOMPARE(settings->property("dateProperty").toDate(), QDate(2000, 01, 02)); // QTBUG-32295: QCOMPARE(settings->property("timeProperty").toDate(), QTime(12, 34, 56)); QCOMPARE(settings->property("sizeProperty").toSizeF(), QSizeF(12, 34)); @@ -474,8 +370,10 @@ void tst_QQmlSettings::aliases() QVERIFY(settings->setProperty("doubleProperty", static_cast(6.78))); QVERIFY(settings->setProperty("stringProperty", QStringLiteral("bar"))); QVERIFY(settings->setProperty("urlProperty", QUrl("https://codereview.qt-project.org"))); + QVERIFY(settings->setProperty("objectProperty", keyValueMap("bar", "baz"))); QVERIFY(settings->setProperty("intListProperty", QVariantList() << 4 << 5 << 6)); QVERIFY(settings->setProperty("stringListProperty", QVariantList() << QStringLiteral("d") << QStringLiteral("e") << QStringLiteral("f"))); + QVERIFY(settings->setProperty("objectListProperty", QVariantList() << keyValueMap("e", "f") << keyValueMap("g", "h"))); QVERIFY(settings->setProperty("dateProperty", QDate(2010, 02, 01))); // QTBUG-32295: QVERIFY(settings->setProperty("timeProperty", QTime(6, 56, 34))); QVERIFY(settings->setProperty("sizeProperty", QSizeF(56, 78))); @@ -492,8 +390,10 @@ void tst_QQmlSettings::aliases() QTRY_COMPARE(qs.value("doubleProperty").toDouble(), static_cast(6.78)); QTRY_COMPARE(qs.value("stringProperty").toString(), QStringLiteral("bar")); QTRY_COMPARE(qs.value("urlProperty").toUrl(), QUrl("https://codereview.qt-project.org")); + QTRY_COMPARE(qs.value("objectProperty").toMap(), keyValueMap("bar", "baz")); QTRY_COMPARE(qs.value("intListProperty").toList(), QVariantList() << 4 << 5 << 6); QTRY_COMPARE(qs.value("stringListProperty").toList(), QVariantList() << QStringLiteral("d") << QStringLiteral("e") << QStringLiteral("f")); + QTRY_COMPARE(qs.value("objectListProperty").toList(), QVariantList() << keyValueMap("e", "f") << keyValueMap("g", "h")); QTRY_COMPARE(qs.value("dateProperty").toDate(), QDate(2010, 02, 01)); // QTBUG-32295: QTRY_COMPARE(qs.value("timeProperty").toDate(), QTime(6, 56, 34)); QTRY_COMPARE(qs.value("sizeProperty").toSizeF(), QSizeF(56, 78)); -- cgit v1.2.3 From bfa220843d3d04bb9be1e1cf35d7e4dd0533df5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCri=20Valdmann?= Date: Tue, 23 May 2017 14:50:42 +0200 Subject: Set LC_TIME in ecmascripttests/test262.py One test fails with LC_TIME=et_EE.UTF-8. The script already sets LANG, but LC_TIME has higher precedence. Change-Id: Ifdb37a1a9d69415d34883343e761d23c6353ef24 Reviewed-by: Simon Hausmann --- tests/auto/qml/ecmascripttests/test262.py | 1 + 1 file changed, 1 insertion(+) (limited to 'tests') diff --git a/tests/auto/qml/ecmascripttests/test262.py b/tests/auto/qml/ecmascripttests/test262.py index 99f029cffd..9f0a7c1dee 100755 --- a/tests/auto/qml/ecmascripttests/test262.py +++ b/tests/auto/qml/ecmascripttests/test262.py @@ -569,6 +569,7 @@ def Main(): #logging.basicConfig(level=logging.DEBUG) os.environ["TZ"] = "PST8PDT" os.environ["LANG"] = "en_US.UTF-8" + os.environ["LC_TIME"] = "en_US.UTF-8" parser = BuildOptions() (options, args) = parser.parse_args() ValidateOptions(options) -- cgit v1.2.3 From 44a5b008f7a6dce065f5997503e403609ee62859 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Tue, 23 May 2017 14:34:23 +0200 Subject: Forward ShortcutOverride in QQuickWidget This is now essential since otherwise these events are simply lost. Amends 0dbc575c1a8359534761167a5f5f1e29abedd51d Task-number: QTBUG-60988 Change-Id: Ib1d99d8fcd5bb92c9b52977796f2910f0fe71c48 Reviewed-by: J-P Nurmi Reviewed-by: Andy Nichols --- .../quickwidgets/qquickwidget/tst_qquickwidget.cpp | 33 ++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'tests') diff --git a/tests/auto/quickwidgets/qquickwidget/tst_qquickwidget.cpp b/tests/auto/quickwidgets/qquickwidget/tst_qquickwidget.cpp index bd051ec990..60495596d1 100644 --- a/tests/auto/quickwidgets/qquickwidget/tst_qquickwidget.cpp +++ b/tests/auto/quickwidgets/qquickwidget/tst_qquickwidget.cpp @@ -59,6 +59,7 @@ private slots: void reparentToNewWindow(); void nullEngine(); void keyEvents(); + void shortcuts(); }; @@ -365,6 +366,38 @@ void tst_qquickwidget::keyEvents() QTRY_VERIFY(widget.ok); } +class ShortcutEventFilter : public QObject +{ +public: + bool eventFilter(QObject *obj, QEvent *e) override { + if (e->type() == QEvent::ShortcutOverride) + shortcutOk = true; + + return QObject::eventFilter(obj, e); + } + + bool shortcutOk = false; +}; + +void tst_qquickwidget::shortcuts() +{ + // Verify that ShortcutOverride events do not get lost. (QTBUG-60988) + KeyHandlingWidget widget; + widget.setSource(testFileUrl("rectangle.qml")); + widget.show(); + QVERIFY(QTest::qWaitForWindowExposed(widget.window(), 5000)); + + // Send to the widget, verify that the QQuickWindow sees it. + + ShortcutEventFilter filter; + widget.quickWindow()->installEventFilter(&filter); + + QKeyEvent e(QEvent::ShortcutOverride, Qt::Key_A, Qt::ControlModifier); + QCoreApplication::sendEvent(&widget, &e); + + QTRY_VERIFY(filter.shortcutOk); +} + QTEST_MAIN(tst_qquickwidget) #include "tst_qquickwidget.moc" -- cgit v1.2.3 From ac02a71a9cb8e80014218ba7de46f4f914b6e00c Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Tue, 30 May 2017 09:11:28 +0200 Subject: Revert "QQuickWindow::createTextureFromImage(): return nullptr for null images" This reverts commit e6acf80136db9f667d0d4664f6c68065355d6811. This breaks behavioral compatibility. Task-number: QTBUG-61083 Change-Id: I0161d536502bab31aaf4ebc38f91e6c8842f72b0 Reviewed-by: Laszlo Agocs --- tests/auto/quick/qquickwindow/tst_qquickwindow.cpp | 11 ----------- 1 file changed, 11 deletions(-) (limited to 'tests') diff --git a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp index 639027d668..1d6547c5be 100644 --- a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp +++ b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp @@ -375,8 +375,6 @@ private slots: void testDragEventPropertyPropagation(); - void createTextureFromImage(); - private: QTouchDevice *touchDevice; QTouchDevice *touchDeviceWithVelocity; @@ -2833,15 +2831,6 @@ void tst_qquickwindow::testDragEventPropertyPropagation() } } -void tst_qquickwindow::createTextureFromImage() -{ - // An invalid image should return a null pointer. - QQuickWindow window; - window.show(); - QTest::qWaitForWindowExposed(&window); - QVERIFY(!window.createTextureFromImage(QImage())); -} - QTEST_MAIN(tst_qquickwindow) #include "tst_qquickwindow.moc" -- cgit v1.2.3 From af6655885cf19de69d5f57ac9daee9f6b9935a70 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Thu, 1 Jun 2017 10:48:00 +0200 Subject: QQuickWindow/View: set a QObject-parent on the root item People are often confused why eg. the objects from: window->contentItem()->findChildren() are not included in window->findChildren(). This change connects the item tree to the window's object tree to make findChild() and findChildren() produce expected results. The same technique is already used for QQuickFlickable's contentItem. [ChangeLog][QtQuick][QQuickWindow] Set the window as the QObject-parent of the contentItem to ensure consistent behavior for calling findChildren() on QQuickWindow and QQuickWindow::contentItem. [ChangeLog][QtQuick][QQuickView] Set the window's contentItem as the QObject-parent of the rootObject to ensure consistent behavior for calling findChildren() on QQuickWindow::contentItem and QQuickView::rootObject. Change-Id: Idb7834eb5e560088ca849e6ce90e6fa3b3ae3e91 Reviewed-by: Mitch Curtis --- tests/auto/quick/qquickview/data/findChild.qml | 9 +++++ tests/auto/quick/qquickview/tst_qquickview.cpp | 40 ++++++++++++++++++++++ tests/auto/quick/qquickwindow/tst_qquickwindow.cpp | 24 +++++++++++++ 3 files changed, 73 insertions(+) create mode 100644 tests/auto/quick/qquickview/data/findChild.qml (limited to 'tests') diff --git a/tests/auto/quick/qquickview/data/findChild.qml b/tests/auto/quick/qquickview/data/findChild.qml new file mode 100644 index 0000000000..8cbc46abe2 --- /dev/null +++ b/tests/auto/quick/qquickview/data/findChild.qml @@ -0,0 +1,9 @@ +import QtQuick 2.0 +Item { + width: 200 + height: 200 + objectName: "rootObject" + Item { + objectName: "rootObjectChild" + } +} diff --git a/tests/auto/quick/qquickview/tst_qquickview.cpp b/tests/auto/quick/qquickview/tst_qquickview.cpp index fa9192edb4..04d21457e6 100644 --- a/tests/auto/quick/qquickview/tst_qquickview.cpp +++ b/tests/auto/quick/qquickview/tst_qquickview.cpp @@ -70,6 +70,7 @@ private slots: void resizemodeitem(); void errors(); void engine(); + void findChild(); }; @@ -265,6 +266,45 @@ void tst_QQuickView::engine() delete view4; } +void tst_QQuickView::findChild() +{ + QQuickView view; + view.setSource(testFileUrl("findChild.qml")); + + // QQuickView + // |_ QQuickWindow::contentItem + // | |_ QQuickView::rootObject: QML Item("rootObject") (findChild.qml) + // | | |_ QML Item("rootObjectChild") (findChild.qml) + // | |_ QObject("contentItemChild") + // |_ QObject("viewChild") + + QObject *viewChild = new QObject(&view); + viewChild->setObjectName("viewChild"); + + QObject *contentItemChild = new QObject(view.contentItem()); + contentItemChild->setObjectName("contentItemChild"); + + QObject *rootObject = view.rootObject(); + QVERIFY(rootObject); + + QObject *rootObjectChild = rootObject->findChild("rootObjectChild"); + QVERIFY(rootObjectChild); + + QCOMPARE(view.findChild("viewChild"), viewChild); + QCOMPARE(view.findChild("contentItemChild"), contentItemChild); + QCOMPARE(view.findChild("rootObject"), rootObject); + QCOMPARE(view.findChild("rootObjectChild"), rootObjectChild); + + QVERIFY(!view.contentItem()->findChild("viewChild")); // sibling + QCOMPARE(view.contentItem()->findChild("contentItemChild"), contentItemChild); + QCOMPARE(view.contentItem()->findChild("rootObject"), rootObject); + QCOMPARE(view.contentItem()->findChild("rootObjectChild"), rootObjectChild); + + QVERIFY(!view.rootObject()->findChild("viewChild")); // ancestor + QVERIFY(!view.rootObject()->findChild("contentItemChild")); // cousin + QVERIFY(!view.rootObject()->findChild("rootObject")); // self +} + QTEST_MAIN(tst_QQuickView) #include "tst_qquickview.moc" diff --git a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp index 1d6547c5be..daa5e53730 100644 --- a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp +++ b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp @@ -375,6 +375,8 @@ private slots: void testDragEventPropertyPropagation(); + void findChild(); + private: QTouchDevice *touchDevice; QTouchDevice *touchDeviceWithVelocity; @@ -2831,6 +2833,28 @@ void tst_qquickwindow::testDragEventPropertyPropagation() } } +void tst_qquickwindow::findChild() +{ + QQuickWindow window; + + // QQuickWindow + // |_ QQuickWindow::contentItem + // | |_ QObject("contentItemChild") + // |_ QObject("viewChild") + + QObject *windowChild = new QObject(&window); + windowChild->setObjectName("windowChild"); + + QObject *contentItemChild = new QObject(window.contentItem()); + contentItemChild->setObjectName("contentItemChild"); + + QCOMPARE(window.findChild("windowChild"), windowChild); + QCOMPARE(window.findChild("contentItemChild"), contentItemChild); + + QVERIFY(!window.contentItem()->findChild("viewChild")); // sibling + QCOMPARE(window.contentItem()->findChild("contentItemChild"), contentItemChild); +} + QTEST_MAIN(tst_qquickwindow) #include "tst_qquickwindow.moc" -- cgit v1.2.3