From 1e8f85dbc90da6b49fa7018ccbc35db68281d395 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Thu, 18 May 2017 16:59:02 +0200 Subject: don't try to pull in the regular config headers when bootstrapping Task-number: QTBUG-60675 Change-Id: I7ae9ab4f442d34f6eaa770652029b5dfccef346a Reviewed-by: Simon Hausmann --- src/qml/qtqmlglobal.h | 16 +++++++++------- src/qml/qtqmlglobal_p.h | 4 +++- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/qml/qtqmlglobal.h b/src/qml/qtqmlglobal.h index 6704e55b52..387c28a945 100644 --- a/src/qml/qtqmlglobal.h +++ b/src/qml/qtqmlglobal.h @@ -40,18 +40,20 @@ #ifndef QTQMLGLOBAL_H #define QTQMLGLOBAL_H +#if defined(QT_BUILD_QMLDEVTOOLS_LIB) || defined(QT_QMLDEVTOOLS_LIB) +# define QT_QML_BOOTSTRAPPED +#endif + #include -#include -#if QT_CONFIG(qml_network) -#include +#ifndef QT_QML_BOOTSTRAPPED +# include +# if QT_CONFIG(qml_network) +# include +# endif #endif QT_BEGIN_NAMESPACE -#if defined(QT_BUILD_QMLDEVTOOLS_LIB) || defined(QT_QMLDEVTOOLS_LIB) -# define QT_QML_BOOTSTRAPPED -#endif - #if !defined(QT_QML_BOOTSTRAPPED) && !defined(QT_STATIC) # if defined(QT_BUILD_QML_LIB) # define Q_QML_EXPORT Q_DECL_EXPORT diff --git a/src/qml/qtqmlglobal_p.h b/src/qml/qtqmlglobal_p.h index e9834ffc4c..0313d8e33b 100644 --- a/src/qml/qtqmlglobal_p.h +++ b/src/qml/qtqmlglobal_p.h @@ -52,8 +52,10 @@ // #include -#include #include +#ifndef QT_QML_BOOTSTRAPPED +# include +#endif #define Q_QML_PRIVATE_EXPORT Q_QML_EXPORT -- cgit v1.2.3 From b078939cb86c7fd82335f4d4a815b6f62eb7b26f Mon Sep 17 00:00:00 2001 From: Robin Burchell Date: Thu, 18 May 2017 12:01:47 +0200 Subject: Revert "QQuickItem: Port a number of manual loops to range-for" This reverts commit 8d92e595e0e8cf19f60db2fce4a543265c9130e9. This is broken in a few places, e.g. setEffectiveVisibleRecur emits, which means that it may run uncontrolled code, so we can't be sure the list isn't altered underneath us. Change-Id: I58b8b62e74581207c1b14902ea7b8b552761de8a Task-number: QTBUG-58811 Reviewed-by: Lars Knoll Reviewed-by: Simon Hausmann Reviewed-by: Shawn Rutledge --- src/quick/items/qquickitem.cpp | 90 +++++++++++++++++++++++++----------------- 1 file changed, 53 insertions(+), 37 deletions(-) diff --git a/src/quick/items/qquickitem.cpp b/src/quick/items/qquickitem.cpp index 8e90827a3d..e280b0bd61 100644 --- a/src/quick/items/qquickitem.cpp +++ b/src/quick/items/qquickitem.cpp @@ -146,8 +146,8 @@ QQuickTransform::QQuickTransform(QQuickTransformPrivate &dd, QObject *parent) QQuickTransform::~QQuickTransform() { Q_D(QQuickTransform); - for (QQuickItem *item : qAsConst(d->items)) { - QQuickItemPrivate *p = QQuickItemPrivate::get(item); + for (int ii = 0; ii < d->items.count(); ++ii) { + QQuickItemPrivate *p = QQuickItemPrivate::get(d->items.at(ii)); p->transforms.removeOne(this); p->dirty(QQuickItemPrivate::Transform); } @@ -156,8 +156,8 @@ QQuickTransform::~QQuickTransform() void QQuickTransform::update() { Q_D(QQuickTransform); - for (QQuickItem *item : qAsConst(d->items)) { - QQuickItemPrivate *p = QQuickItemPrivate::get(item); + for (int ii = 0; ii < d->items.count(); ++ii) { + QQuickItemPrivate *p = QQuickItemPrivate::get(d->items.at(ii)); p->dirty(QQuickItemPrivate::Transform); } } @@ -169,7 +169,9 @@ QQuickContents::QQuickContents(QQuickItem *item) QQuickContents::~QQuickContents() { - for (QQuickItem *child : m_item->childItems()) { + QList children = m_item->childItems(); + for (int i = 0; i < children.count(); ++i) { + QQuickItem *child = children.at(i); QQuickItemPrivate::get(child)->removeItemChangeListener(this, QQuickItemPrivate::Geometry | QQuickItemPrivate::Destroyed); } } @@ -192,8 +194,9 @@ bool QQuickContents::calcHeight(QQuickItem *changed) } else { qreal top = std::numeric_limits::max(); qreal bottom = -std::numeric_limits::max(); - const QList children = m_item->childItems(); - for (QQuickItem *child : qAsConst(children)) { + QList children = m_item->childItems(); + for (int i = 0; i < children.count(); ++i) { + QQuickItem *child = children.at(i); qreal y = child->y(); if (y + child->height() > bottom) bottom = y + child->height(); @@ -226,8 +229,9 @@ bool QQuickContents::calcWidth(QQuickItem *changed) } else { qreal left = std::numeric_limits::max(); qreal right = -std::numeric_limits::max(); - const QList children = m_item->childItems(); - for (QQuickItem *child : qAsConst(children)) { + QList children = m_item->childItems(); + for (int i = 0; i < children.count(); ++i) { + QQuickItem *child = children.at(i); qreal x = child->x(); if (x + child->width() > right) right = x + child->width(); @@ -246,7 +250,9 @@ void QQuickContents::complete() { QQuickItemPrivate::get(m_item)->addItemChangeListener(this, QQuickItemPrivate::Children); - for (QQuickItem *child : m_item->childItems()) { + QList children = m_item->childItems(); + for (int i = 0; i < children.count(); ++i) { + QQuickItem *child = children.at(i); QQuickItemPrivate::get(child)->addItemChangeListener(this, QQuickItemPrivate::Geometry | QQuickItemPrivate::Destroyed); //###what about changes to visibility? } @@ -1347,7 +1353,8 @@ void QQuickKeysAttached::componentComplete() #if QT_CONFIG(im) Q_D(QQuickKeysAttached); if (d->item) { - for (QQuickItem *targetItem : qAsConst(d->targets)) { + for (int ii = 0; ii < d->targets.count(); ++ii) { + QQuickItem *targetItem = d->targets.at(ii); if (targetItem && (targetItem->flags() & QQuickItem::ItemAcceptsInputMethod)) { d->item->setFlag(QQuickItem::ItemAcceptsInputMethod); break; @@ -1369,10 +1376,11 @@ void QQuickKeysAttached::keyPressed(QKeyEvent *event, bool post) // first process forwards if (d->item && d->item->window()) { d->inPress = true; - for (QQuickItem *targetItem : qAsConst(d->targets)) { - if (targetItem && targetItem->isVisible()) { + for (int ii = 0; ii < d->targets.count(); ++ii) { + QQuickItem *i = d->targets.at(ii); + if (i && i->isVisible()) { event->accept(); - QCoreApplication::sendEvent(targetItem, event); + QCoreApplication::sendEvent(i, event); if (event->isAccepted()) { d->inPress = false; return; @@ -1412,10 +1420,11 @@ void QQuickKeysAttached::keyReleased(QKeyEvent *event, bool post) if (d->item && d->item->window()) { d->inRelease = true; - for (QQuickItem *targetItem : qAsConst(d->targets)) { - if (targetItem && targetItem->isVisible()) { + for (int ii = 0; ii < d->targets.count(); ++ii) { + QQuickItem *i = d->targets.at(ii); + if (i && i->isVisible()) { event->accept(); - QCoreApplication::sendEvent(targetItem, event); + QCoreApplication::sendEvent(i, event); if (event->isAccepted()) { d->inRelease = false; return; @@ -1439,7 +1448,8 @@ void QQuickKeysAttached::inputMethodEvent(QInputMethodEvent *event, bool post) Q_D(QQuickKeysAttached); if (post == m_processPost && d->item && !d->inIM && d->item->window()) { d->inIM = true; - for (QQuickItem *targetItem : qAsConst(d->targets)) { + for (int ii = 0; ii < d->targets.count(); ++ii) { + QQuickItem *targetItem = d->targets.at(ii); if (targetItem && targetItem->isVisible() && (targetItem->flags() & QQuickItem::ItemAcceptsInputMethod)) { QCoreApplication::sendEvent(targetItem, event); if (event->isAccepted()) { @@ -1458,12 +1468,13 @@ QVariant QQuickKeysAttached::inputMethodQuery(Qt::InputMethodQuery query) const { Q_D(const QQuickKeysAttached); if (d->item) { - for (QQuickItem *targetItem : qAsConst(d->targets)) { - if (targetItem && targetItem->isVisible() && (targetItem->flags() & QQuickItem::ItemAcceptsInputMethod) && targetItem == d->imeItem) { - //### how robust is targetItem == d->imeItem check? - QVariant v = targetItem->inputMethodQuery(query); + for (int ii = 0; ii < d->targets.count(); ++ii) { + QQuickItem *i = d->targets.at(ii); + if (i && i->isVisible() && (i->flags() & QQuickItem::ItemAcceptsInputMethod) && i == d->imeItem) { + //### how robust is i == d->imeItem check? + QVariant v = i->inputMethodQuery(query); if (v.userType() == QVariant::RectF) - v = d->item->mapRectFromItem(targetItem, v.toRectF()); //### cost? + v = d->item->mapRectFromItem(i, v.toRectF()); //### cost? return v; } } @@ -1637,9 +1648,11 @@ void QQuickItemPrivate::setImplicitLayoutMirror(bool mirror, bool inherit) if (isMirrorImplicit) setLayoutMirror(inherit ? inheritedLayoutMirror : false); - for (QQuickItem *child : qAsConst(childItems)) { - QQuickItemPrivate *childPrivate = QQuickItemPrivate::get(child); - childPrivate->setImplicitLayoutMirror(inheritedLayoutMirror, inheritMirrorFromParent); + for (int i = 0; i < childItems.count(); ++i) { + if (QQuickItem *child = qmlobject_cast(childItems.at(i))) { + QQuickItemPrivate *childPrivate = QQuickItemPrivate::get(child); + childPrivate->setImplicitLayoutMirror(inheritedLayoutMirror, inheritMirrorFromParent); + } } } @@ -2395,7 +2408,8 @@ QQuickItem::~QQuickItem() remove themselves from our list of transforms when that list has already been destroyed after ~QQuickItem() has run. */ - for (QQuickTransform *t : qAsConst(d->transforms)) { + for (int ii = 0; ii < d->transforms.count(); ++ii) { + QQuickTransform *t = d->transforms.at(ii); QQuickTransformPrivate *tp = QQuickTransformPrivate::get(t); tp->items.removeOne(this); } @@ -2886,8 +2900,8 @@ QList QQuickItemPrivate::paintOrderChildItems() const // If none of the items have set Z then the paint order list is the same as // the childItems list. This is by far the most common case. bool haveZ = false; - for (QQuickItem *childItem : qAsConst(childItems)) { - if (QQuickItemPrivate::get(childItem)->z() != 0.) { + for (int i = 0; i < childItems.count(); ++i) { + if (QQuickItemPrivate::get(childItems.at(i))->z() != 0.) { haveZ = true; break; } @@ -2988,7 +3002,8 @@ void QQuickItemPrivate::refWindow(QQuickWindow *c) if (!parentItem) QQuickWindowPrivate::get(window)->parentlessItems.insert(q); - for (QQuickItem *child : qAsConst(childItems)) { + for (int ii = 0; ii < childItems.count(); ++ii) { + QQuickItem *child = childItems.at(ii); QQuickItemPrivate::get(child)->refWindow(c); } @@ -3040,7 +3055,8 @@ void QQuickItemPrivate::derefWindow() paintNode = 0; - for (QQuickItem *child : qAsConst(childItems)) { + for (int ii = 0; ii < childItems.count(); ++ii) { + QQuickItem *child = childItems.at(ii); QQuickItemPrivate::get(child)->derefWindow(); } @@ -3485,7 +3501,8 @@ void QQuickItemPrivate::transform_clear(QQmlListProperty *prop) QQuickItem *that = static_cast(prop->object); QQuickItemPrivate *p = QQuickItemPrivate::get(that); - for (QQuickTransform *t : qAsConst(p->transforms)) { + for (int ii = 0; ii < p->transforms.count(); ++ii) { + QQuickTransform *t = p->transforms.at(ii); QQuickTransformPrivate *tp = QQuickTransformPrivate::get(t); tp->items.removeOne(that); } @@ -5850,9 +5867,8 @@ bool QQuickItemPrivate::setEffectiveVisibleRecur(bool newEffectiveVisible) } bool childVisibilityChanged = false; - for (QQuickItem *childItem : qAsConst(childItems)) { - childVisibilityChanged |= QQuickItemPrivate::get(childItem)->setEffectiveVisibleRecur(newEffectiveVisible); - } + for (int ii = 0; ii < childItems.count(); ++ii) + childVisibilityChanged |= QQuickItemPrivate::get(childItems.at(ii))->setEffectiveVisibleRecur(newEffectiveVisible); itemChange(QQuickItem::ItemVisibleHasChanged, effectiveVisible); #if QT_CONFIG(accessibility) @@ -5901,8 +5917,8 @@ void QQuickItemPrivate::setEffectiveEnableRecur(QQuickItem *scope, bool newEffec } } - for (QQuickItem *childItem : qAsConst(childItems)) { - QQuickItemPrivate::get(childItem)->setEffectiveEnableRecur( + for (int ii = 0; ii < childItems.count(); ++ii) { + QQuickItemPrivate::get(childItems.at(ii))->setEffectiveEnableRecur( (flags & QQuickItem::ItemIsFocusScope) && scope ? q : scope, newEffectiveEnable); } -- cgit v1.2.3 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 --- src/qml/compiler/qqmlirbuilder.cpp | 5 +++-- 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 +++++++++++ 5 files changed, 37 insertions(+), 2 deletions(-) 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 diff --git a/src/qml/compiler/qqmlirbuilder.cpp b/src/qml/compiler/qqmlirbuilder.cpp index 9f2c2294ed..16eee50cf9 100644 --- a/src/qml/compiler/qqmlirbuilder.cpp +++ b/src/qml/compiler/qqmlirbuilder.cpp @@ -1924,7 +1924,7 @@ QV4::IR::Expr *JSCodeGen::fallbackNameLookup(const QString &name, int line, int // with the correct QML context. // Look for IDs first. - for (const IdMapping &mapping : qAsConst(_idObjects)) + for (const IdMapping &mapping : qAsConst(_idObjects)) { if (name == mapping.name) { if (_function->isQmlBinding) _function->idObjectDependencies.insert(mapping.idIndex); @@ -1942,8 +1942,9 @@ QV4::IR::Expr *JSCodeGen::fallbackNameLookup(const QString &name, int line, int result->isReadOnly = true; // don't allow use as lvalue return result; } + } - { + if (name.at(0).isUpper()) { QQmlTypeNameCache::Result r = imports->query(name); if (r.isValid()) { if (r.scriptIndex != -1) { 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 --- dist/changes-5.9.0 | 1 + src/imports/settings/qqmlsettings.cpp | 18 +- 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 ++++++----------------- 6 files changed, 81 insertions(+), 156 deletions(-) diff --git a/dist/changes-5.9.0 b/dist/changes-5.9.0 index f6c6aebea9..7cd655e384 100644 --- a/dist/changes-5.9.0 +++ b/dist/changes-5.9.0 @@ -43,6 +43,7 @@ QtQml to allow getting the actual storage path for a particular database. - [QTBUG-53091] Introduced Qt.application.displayName, to map the QGuiApplication::applicationDisplayName property to QML. + - [QTBUG-45316] QML Settings has been fixed to handle JavaScript arrays. QtQuick ------- diff --git a/src/imports/settings/qqmlsettings.cpp b/src/imports/settings/qqmlsettings.cpp index cd6fcbc718..df67c04654 100644 --- a/src/imports/settings/qqmlsettings.cpp +++ b/src/imports/settings/qqmlsettings.cpp @@ -41,6 +41,7 @@ #include #include #include +#include #include #include @@ -241,6 +242,7 @@ public: void store(); void _q_propertyChanged(); + QVariant readProperty(const QMetaProperty &property) const; QQmlSettings *q_ptr; int timerId; @@ -295,7 +297,7 @@ void QQmlSettingsPrivate::load() for (int i = offset; i < count; ++i) { QMetaProperty property = mo->property(i); - const QVariant previousValue = property.read(q); + const QVariant previousValue = readProperty(property); const QVariant currentValue = instance()->value(property.name(), previousValue); if (!currentValue.isNull() && (!previousValue.isValid() @@ -340,9 +342,10 @@ void QQmlSettingsPrivate::_q_propertyChanged() const int count = mo->propertyCount(); for (int i = offset; i < count; ++i) { const QMetaProperty &property = mo->property(i); - changedProperties.insert(property.name(), property.read(q)); + const QVariant value = readProperty(property); + changedProperties.insert(property.name(), value); #ifdef SETTINGS_DEBUG - qDebug() << "QQmlSettings: cache" << property.name() << ":" << property.read(q); + qDebug() << "QQmlSettings: cache" << property.name() << ":" << value; #endif } if (timerId != 0) @@ -350,6 +353,15 @@ void QQmlSettingsPrivate::_q_propertyChanged() timerId = q->startTimer(settingsWriteDelay); } +QVariant QQmlSettingsPrivate::readProperty(const QMetaProperty &property) const +{ + Q_Q(const QQmlSettings); + QVariant var = property.read(q); + if (var.userType() == qMetaTypeId()) + var = var.value().toVariant(); + return var; +} + QQmlSettings::QQmlSettings(QObject *parent) : QObject(parent), d_ptr(new QQmlSettingsPrivate) { 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 96f6ba5f562073f508cd8569ac354592fdd48f4a Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Thu, 11 May 2017 20:36:51 +0200 Subject: Revert "Temporarily restore QQuickPointerDevice::pointerEvent() accessor" This reverts commit ee6b07b3ce8ba80632868181d45d96253acb1064. This is to be integrated after the qtlocation change to remove the dependency on this private function. Task-number: QTBUG-57253 Change-Id: I756681fb2595d1326b7e5206bac57ccc318c0a46 Reviewed-by: Liang Qi --- src/quick/items/qquickevents_p_p.h | 7 ------- src/quick/items/qquickwindow.cpp | 5 +---- 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/src/quick/items/qquickevents_p_p.h b/src/quick/items/qquickevents_p_p.h index 323ecfa4ff..3735d68a85 100644 --- a/src/quick/items/qquickevents_p_p.h +++ b/src/quick/items/qquickevents_p_p.h @@ -501,7 +501,6 @@ public: : m_deviceType(devType), m_pointerType(pType), m_capabilities(caps) , m_maximumTouchPoints(maxPoints), m_buttonCount(buttonCount), m_name(name) , m_uniqueId(QPointingDeviceUniqueId::fromNumericId(uniqueId)) - , m_event(nullptr) { } @@ -514,8 +513,6 @@ public: QString name() const { return m_name; } QPointingDeviceUniqueId uniqueId() const { return m_uniqueId; } - QQuickPointerEvent *pointerEvent() const { return m_event; } // deprecated - static QQuickPointerDevice *touchDevice(QTouchDevice *d); static QList touchDevices(); static QQuickPointerDevice *genericMouseDevice(); @@ -530,10 +527,6 @@ private: QString m_name; QPointingDeviceUniqueId m_uniqueId; - // the event instance used last time within the context of one window - QQuickPointerEvent *m_event; // deprecated - friend class QQuickWindowPrivate; // not needed after removing the above - Q_DISABLE_COPY(QQuickPointerDevice) }; diff --git a/src/quick/items/qquickwindow.cpp b/src/quick/items/qquickwindow.cpp index 816c057ab0..c441cfc357 100644 --- a/src/quick/items/qquickwindow.cpp +++ b/src/quick/items/qquickwindow.cpp @@ -2117,10 +2117,8 @@ QQuickPointerEvent *QQuickWindowPrivate::pointerEventInstance(QQuickPointerDevic { // the list of devices should be very small so a linear search should be ok for (QQuickPointerEvent *e: pointerEventInstances) { - if (e->device() == device) { - device->m_event = e; + if (e->device() == device) return e; - } } QQuickPointerEvent *ev = nullptr; @@ -2138,7 +2136,6 @@ QQuickPointerEvent *QQuickWindowPrivate::pointerEventInstance(QQuickPointerDevic break; } pointerEventInstances << ev; - device->m_event = ev; return ev; } -- cgit v1.2.3 From 16105b1b0cf9dc3849d9ff03503fa8bed1b8da40 Mon Sep 17 00:00:00 2001 From: Marco Benelli Date: Fri, 19 May 2017 11:27:48 +0200 Subject: Update qmltypes Small update of qmltypes. Change-Id: I5408f0ae50a70ca1c1cc0c0deaa8ddf6458c88c1 Reviewed-by: Thomas Hartmann Reviewed-by: Erik Verbruggen --- src/imports/builtins/builtins.qmltypes | 3 ++- src/imports/qtquick2/plugins.qmltypes | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/imports/builtins/builtins.qmltypes b/src/imports/builtins/builtins.qmltypes index ac95a8837b..c2f8f5b521 100644 --- a/src/imports/builtins/builtins.qmltypes +++ b/src/imports/builtins/builtins.qmltypes @@ -426,7 +426,8 @@ Module { "WA_X11DoNotAcceptFocus": 126, "WA_MacNoShadow": 127, "WA_AlwaysStackOnTop": 128, - "WA_AttributeCount": 129 + "WA_TabletTracking": 129, + "WA_AttributeCount": 130 } } Enum { diff --git a/src/imports/qtquick2/plugins.qmltypes b/src/imports/qtquick2/plugins.qmltypes index a9534b5ccc..834b4bfac2 100644 --- a/src/imports/qtquick2/plugins.qmltypes +++ b/src/imports/qtquick2/plugins.qmltypes @@ -1414,7 +1414,7 @@ Module { Property { name: "source"; type: "QObject"; isPointer: true } Property { name: "target"; type: "QObject"; isReadonly: true; isPointer: true } Property { name: "hotSpot"; type: "QPointF" } - Property { name: "imageSource"; revision: 8; type: "QUrl" } + Property { name: "imageSource"; type: "QUrl" } Property { name: "keys"; type: "QStringList" } Property { name: "mimeData"; type: "QVariantMap" } Property { name: "supportedActions"; type: "Qt::DropActions" } -- cgit v1.2.3 From 101bd41490be160be218aa638f35cfa609267a83 Mon Sep 17 00:00:00 2001 From: Andy Nichols Date: Tue, 23 May 2017 12:13:35 +0200 Subject: Software: Fix QQuickWidget rendering in QMdiArea It is not safe to assume that the paintRegion is always the same as the updateRegion reported by the software renderer, since in some cases more needs to be flushed, such as in the case of the QMdiArea. Now we make sure to unite both of these regions and flush everything needed. Task-number: QTBUG-60985 Change-Id: I0408c21e42dd4107b0974877144e8e93f2c30fae Reviewed-by: Laszlo Agocs --- src/quickwidgets/qquickwidget.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/quickwidgets/qquickwidget.cpp b/src/quickwidgets/qquickwidget.cpp index 4d021cb680..49ac0caefd 100644 --- a/src/quickwidgets/qquickwidget.cpp +++ b/src/quickwidgets/qquickwidget.cpp @@ -1596,10 +1596,10 @@ QQuickWindow *QQuickWidget::quickWindow() const void QQuickWidget::paintEvent(QPaintEvent *event) { - Q_UNUSED(event) Q_D(QQuickWidget); if (d->useSoftwareRenderer) { QPainter painter(this); + d->updateRegion = d->updateRegion.united(event->region()); if (d->updateRegion.isNull()) { //Paint everything painter.drawImage(rect(), d->softwareImage); -- cgit v1.2.3 From 082d7361ae54cc9081a7e33ae7bd49949dfb3e08 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 23 May 2017 12:59:14 +0200 Subject: QtQml: Restrict alloca definition to MSVC Fix developer build with MinGW: In file included from memory\qv4mm.cpp:60:0: jsruntime/qv4alloca_p.h:62:0: error: "alloca" redefined [-Werror] # define alloca _alloca ^ In file included from .../mingw32/i686-w64-mingw32/include/stdlib.h:686:0, from .../mingw32/i686-w64-mingw32/include/c++/cstdlib:72, from .../mingw32/i686-w64-mingw32/include/c++/bits/stl_algo.h:59, from .../mingw32/i686-w64-mingw32/include/c++/algorithm:62, from .../qtbase/src/corelib/global/qglobal.h:109, from ...\qtbase\include/QtCore/qglobal.h:1, from jsruntime/qv4global_p.h:54, from jsruntime/qv4engine_p.h:53, from memory\qv4mm.cpp:40: .../mingw32/i686-w64-mingw32/include/malloc.h:183:0: note: this is the location of the previous definition #define alloca(x) __builtin_alloca((x)) Amends change a225bddf67f4786c845193630d4ab20b99a2fc3a. Change-Id: I4a758776dbf78225f62883393eb50b7121297a1b Reviewed-by: Simon Hausmann --- src/qml/jsruntime/qv4alloca_p.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qml/jsruntime/qv4alloca_p.h b/src/qml/jsruntime/qv4alloca_p.h index c21878fa42..1e9f83a90e 100644 --- a/src/qml/jsruntime/qv4alloca_p.h +++ b/src/qml/jsruntime/qv4alloca_p.h @@ -58,7 +58,7 @@ #elif QT_CONFIG(alloca_malloc_h) # include // This does not matter unless compiling in strict standard mode. -# ifdef Q_OS_WIN +# ifdef Q_CC_MSVC # define alloca _alloca # endif #else -- cgit v1.2.3 From 4b71719d1c02e484192e5b840e0937e1778d33c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCri=20Valdmann?= Date: Mon, 15 May 2017 12:24:41 +0200 Subject: Improve dirty region calculation in software renderer The software renderers dirty region calculation is done in integral logical coordinates, which leads to quite some trouble when handling scene graph elements with fractional coordinates (used by WebEngine for example). The optimal solution would probably be to either use integral physical coordinates or floating point logical coordinates, however this would seem to require substantial changes to QPainter and QBackingStore and so on. So, this patch instead changes the calculation to use something like interval arithmetic: instead of just rounding each logical coordinate to the nearest integer the renderer now uses (very carefully) both the upper and lower boundaries to make sure that the dirty regions always err on the side of caution. I expect this change to make rendering slower but only in situations where previously there would be rendering errors. Task-number: QTBUG-60393 Change-Id: I7f8e7d2739c810328c841130df9c1c7332439447 Reviewed-by: Andy Nichols --- .../software/qsgabstractsoftwarerenderer.cpp | 8 +-- .../software/qsgsoftwarerenderablenode.cpp | 77 +++++++++++++--------- .../software/qsgsoftwarerenderablenode_p.h | 6 +- 3 files changed, 55 insertions(+), 36 deletions(-) diff --git a/src/quick/scenegraph/adaptations/software/qsgabstractsoftwarerenderer.cpp b/src/quick/scenegraph/adaptations/software/qsgabstractsoftwarerenderer.cpp index 2ff180ea99..02cf8209d1 100644 --- a/src/quick/scenegraph/adaptations/software/qsgabstractsoftwarerenderer.cpp +++ b/src/quick/scenegraph/adaptations/software/qsgabstractsoftwarerenderer.cpp @@ -165,12 +165,12 @@ QRegion QSGAbstractSoftwareRenderer::optimizeRenderList() // Keep up with obscured regions if (node->isOpaque()) { - m_obscuredRegion += QRegion(node->boundingRect()); + m_obscuredRegion += node->boundingRectMin(); } if (node->isDirty()) { // Don't paint things outside of the rendering area - if (!m_background->rect().toRect().contains(node->boundingRect(), /*proper*/ true)) { + if (!m_background->rect().toRect().contains(node->boundingRectMax(), /*proper*/ true)) { // Some part(s) of node is(are) outside of the rendering area QRegion renderArea(m_background->rect().toRect()); QRegion outsideRegions = node->dirtyRegion().subtracted(renderArea); @@ -181,7 +181,7 @@ QRegion QSGAbstractSoftwareRenderer::optimizeRenderList() // Get the dirty region's to pass to the next nodes if (node->isOpaque()) { // if isOpaque, subtract node's dirty rect from m_dirtyRegion - m_dirtyRegion -= node->dirtyRegion(); + m_dirtyRegion -= node->boundingRectMin(); } else { // if isAlpha, add node's dirty rect to m_dirtyRegion m_dirtyRegion += node->dirtyRegion(); @@ -264,7 +264,7 @@ void QSGAbstractSoftwareRenderer::nodeRemoved(QSGNode *node) // Need to mark this region dirty in the other nodes QRegion dirtyRegion = renderable->previousDirtyRegion(true); if (dirtyRegion.isEmpty()) - dirtyRegion = renderable->boundingRect(); + dirtyRegion = renderable->boundingRectMax(); m_dirtyRegion += dirtyRegion; m_nodes.remove(node); delete renderable; diff --git a/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderablenode.cpp b/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderablenode.cpp index 59c47db0c4..ce08d18057 100644 --- a/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderablenode.cpp +++ b/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderablenode.cpp @@ -54,10 +54,28 @@ #include #include +#include + Q_LOGGING_CATEGORY(lcRenderable, "qt.scenegraph.softwarecontext.renderable") QT_BEGIN_NAMESPACE +// Largest subrectangle with integer coordinates +inline QRect toRectMin(const QRectF & r) +{ + int x1 = qCeil(r.left()); + int x2 = qFloor(r.right()); + int y1 = qCeil(r.top()); + int y2 = qFloor(r.bottom()); + return QRect(x1, y1, x2 - x1, y2 - y1); +} + +// Smallest superrectangle with integer coordinates +inline QRect toRectMax(const QRectF & r) +{ + return r.toAlignedRect(); +} + QSGSoftwareRenderableNode::QSGSoftwareRenderableNode(NodeType type, QSGNode *node) : m_nodeType(type) , m_isOpaque(true) @@ -117,7 +135,7 @@ void QSGSoftwareRenderableNode::update() // Update the Node properties m_isDirty = true; - QRect boundingRect; + QRectF boundingRect; switch (m_nodeType) { case QSGSoftwareRenderableNode::SimpleRect: @@ -126,7 +144,7 @@ void QSGSoftwareRenderableNode::update() else m_isOpaque = false; - boundingRect = m_handle.simpleRectNode->rect().toRect(); + boundingRect = m_handle.simpleRectNode->rect(); break; case QSGSoftwareRenderableNode::SimpleTexture: if (!m_handle.simpleTextureNode->texture()->hasAlphaChannel() && !m_transform.isRotating()) @@ -134,7 +152,7 @@ void QSGSoftwareRenderableNode::update() else m_isOpaque = false; - boundingRect = m_handle.simpleTextureNode->rect().toRect(); + boundingRect = m_handle.simpleTextureNode->rect(); break; case QSGSoftwareRenderableNode::Image: // There isn't a way to tell, so assume it's not @@ -148,7 +166,7 @@ void QSGSoftwareRenderableNode::update() else m_isOpaque = false; - boundingRect = QRect(0, 0, m_handle.painterNode->size().width(), m_handle.painterNode->size().height()); + boundingRect = QRectF(0, 0, m_handle.painterNode->size().width(), m_handle.painterNode->size().height()); break; case QSGSoftwareRenderableNode::Rectangle: if (m_handle.rectangleNode->isOpaque() && !m_transform.isRotating()) @@ -156,19 +174,19 @@ void QSGSoftwareRenderableNode::update() else m_isOpaque = false; - boundingRect = m_handle.rectangleNode->rect().toRect(); + boundingRect = m_handle.rectangleNode->rect(); break; case QSGSoftwareRenderableNode::Glyph: // Always has alpha m_isOpaque = false; - boundingRect = m_handle.glpyhNode->boundingRect().toAlignedRect(); + boundingRect = m_handle.glpyhNode->boundingRect(); break; case QSGSoftwareRenderableNode::NinePatch: // Difficult to tell, assume non-opaque m_isOpaque = false; - boundingRect = m_handle.ninePatchNode->bounds().toRect(); + boundingRect = m_handle.ninePatchNode->bounds(); break; case QSGSoftwareRenderableNode::SimpleRectangle: if (m_handle.simpleRectangleNode->color().alpha() == 255 && !m_transform.isRotating()) @@ -176,7 +194,7 @@ void QSGSoftwareRenderableNode::update() else m_isOpaque = false; - boundingRect = m_handle.simpleRectangleNode->rect().toRect(); + boundingRect = m_handle.simpleRectangleNode->rect(); break; case QSGSoftwareRenderableNode::SimpleImage: if (!m_handle.simpleImageNode->texture()->hasAlphaChannel() && !m_transform.isRotating()) @@ -184,12 +202,12 @@ void QSGSoftwareRenderableNode::update() else m_isOpaque = false; - boundingRect = m_handle.simpleImageNode->rect().toRect(); + boundingRect = m_handle.simpleImageNode->rect(); break; #if QT_CONFIG(quick_sprite) case QSGSoftwareRenderableNode::SpriteNode: m_isOpaque = m_handle.spriteNode->isOpaque(); - boundingRect = m_handle.spriteNode->rect().toRect(); + boundingRect = m_handle.spriteNode->rect(); break; #endif case QSGSoftwareRenderableNode::RenderNode: @@ -198,27 +216,32 @@ void QSGSoftwareRenderableNode::update() else m_isOpaque = false; - boundingRect = m_handle.renderNode->rect().toRect(); + boundingRect = m_handle.renderNode->rect(); break; default: break; } - m_boundingRect = m_transform.mapRect(boundingRect); + const QRectF transformedRect = m_transform.mapRect(boundingRect); + m_boundingRectMin = toRectMin(transformedRect); + m_boundingRectMax = toRectMax(transformedRect); if (m_hasClipRegion && m_clipRegion.rectCount() <= 1) { // If there is a clipRegion, and it is empty, the item wont be rendered - if (m_clipRegion.isEmpty()) - m_boundingRect = QRect(); - else - m_boundingRect = m_boundingRect.intersected(m_clipRegion.rects().first()); + if (m_clipRegion.isEmpty()) { + m_boundingRectMin = QRect(); + m_boundingRectMax = QRect(); + } else { + m_boundingRectMin = m_boundingRectMin.intersected(m_clipRegion.rects().first()); + m_boundingRectMax = m_boundingRectMax.intersected(m_clipRegion.rects().first()); + } } // Overrides if (m_opacity < 1.0f) m_isOpaque = false; - m_dirtyRegion = QRegion(m_boundingRect); + m_dirtyRegion = QRegion(m_boundingRectMax); } struct RenderNodeState : public QSGRenderNode::RenderState @@ -258,7 +281,7 @@ QRegion QSGSoftwareRenderableNode::renderNode(QPainter *painter, bool forceOpaqu rs.cr = m_clipRegion; const QRect br = m_handle.renderNode->flags().testFlag(QSGRenderNode::BoundedRectRendering) - ? m_boundingRect : + ? m_boundingRectMax : QRect(0, 0, painter->device()->width(), painter->device()->height()); painter->save(); @@ -335,19 +358,13 @@ QRegion QSGSoftwareRenderableNode::renderNode(QPainter *painter, bool forceOpaqu painter->restore(); QRegion areaToBeFlushed = m_dirtyRegion; - m_previousDirtyRegion = QRegion(m_boundingRect); + m_previousDirtyRegion = QRegion(m_boundingRectMax); m_isDirty = false; m_dirtyRegion = QRegion(); return areaToBeFlushed; } -QRect QSGSoftwareRenderableNode::boundingRect() const -{ - // This returns the bounding area of a renderable node in world coordinates - return m_boundingRect; -} - bool QSGSoftwareRenderableNode::isDirtyRegionEmpty() const { return m_dirtyRegion.isEmpty(); @@ -392,12 +409,12 @@ void QSGSoftwareRenderableNode::markMaterialDirty() void QSGSoftwareRenderableNode::addDirtyRegion(const QRegion &dirtyRegion, bool forceDirty) { - // Check if the dirty region applys to this node + // Check if the dirty region applies to this node QRegion prev = m_dirtyRegion; - if (dirtyRegion.intersects(boundingRect())) { + if (dirtyRegion.intersects(m_boundingRectMax)) { if (forceDirty) m_isDirty = true; - m_dirtyRegion += dirtyRegion.intersected(boundingRect()); + m_dirtyRegion += dirtyRegion.intersected(m_boundingRectMax); } qCDebug(lcRenderable) << "addDirtyRegion: " << dirtyRegion << "old dirtyRegion: " << prev << "new dirtyRegion: " << m_dirtyRegion; } @@ -407,7 +424,7 @@ void QSGSoftwareRenderableNode::subtractDirtyRegion(const QRegion &dirtyRegion) QRegion prev = m_dirtyRegion; if (m_isDirty) { // Check if this rect concerns us - if (dirtyRegion.intersects(QRegion(boundingRect()))) { + if (dirtyRegion.intersects(m_boundingRectMax)) { m_dirtyRegion -= dirtyRegion; if (m_dirtyRegion.isEmpty()) m_isDirty = false; @@ -423,7 +440,7 @@ QRegion QSGSoftwareRenderableNode::previousDirtyRegion(bool wasRemoved) const if (wasRemoved) return m_previousDirtyRegion; - return m_previousDirtyRegion.subtracted(QRegion(m_boundingRect)); + return m_previousDirtyRegion.subtracted(QRegion(m_boundingRectMax)); } QRegion QSGSoftwareRenderableNode::dirtyRegion() const diff --git a/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderablenode_p.h b/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderablenode_p.h index 473578c185..8fc87db179 100644 --- a/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderablenode_p.h +++ b/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderablenode_p.h @@ -98,7 +98,8 @@ public: void update(); QRegion renderNode(QPainter *painter, bool forceOpaquePainting = false); - QRect boundingRect() const; + QRect boundingRectMin() const { return m_boundingRectMin; } + QRect boundingRectMax() const { return m_boundingRectMax; } NodeType type() const { return m_nodeType; } bool isOpaque() const { return m_isOpaque; } bool isDirty() const { return m_isDirty; } @@ -149,7 +150,8 @@ private: bool m_hasClipRegion; float m_opacity; - QRect m_boundingRect; + QRect m_boundingRectMin; + QRect m_boundingRectMax; }; QT_END_NAMESPACE -- 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(+) 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 a5fbfc9ab1dc06c9f80beda2179b15bd7c499c77 Mon Sep 17 00:00:00 2001 From: Jesus Fernandez Date: Mon, 22 May 2017 09:49:18 +0200 Subject: Document the default value of x, y, width & height The default values of the coordinates and size variables were missing. Change-Id: I1bba77b3db68d3f726c1211c6a0090e97f687b51 Reviewed-by: Mitch Curtis Reviewed-by: Shawn Rutledge --- src/quick/items/qquickitem.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/quick/items/qquickitem.cpp b/src/quick/items/qquickitem.cpp index 8e90827a3d..5f5611d711 100644 --- a/src/quick/items/qquickitem.cpp +++ b/src/quick/items/qquickitem.cpp @@ -6343,6 +6343,7 @@ void QQuickItem::setFlags(Flags flags) \qmlproperty real QtQuick::Item::height Defines the item's position and size. + The default value is \c 0. The (x,y) position is relative to the \l parent. -- cgit v1.2.3 From df30d90eadcd92eebb4bf79f3eb251bc58d25d09 Mon Sep 17 00:00:00 2001 From: Liang Qi Date: Tue, 23 May 2017 17:09:32 +0200 Subject: Revert "Fix compilation of QtScxml" This reverts commit 3f9367cb32533b691cb8c761213f21a524e3d1cb. QtScxml adapted to new API. Task-number: QTBUG-60938 Change-Id: I417b604ceb9949ee3c0197ac9f88efdbe53ebe48 Reviewed-by: Simon Hausmann --- src/qml/jsruntime/qv4string_p.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/qml/jsruntime/qv4string_p.h b/src/qml/jsruntime/qv4string_p.h index d9625e3f4e..f5311ae5d4 100644 --- a/src/qml/jsruntime/qv4string_p.h +++ b/src/qml/jsruntime/qv4string_p.h @@ -175,10 +175,6 @@ struct Q_QML_PRIVATE_EXPORT String : public Managed { } uint toUInt(bool *ok) const; - Q_DECL_DEPRECATED void makeIdentifier(ExecutionEngine *) { - makeIdentifier(); - } - void makeIdentifier() const { if (d()->identifier) return; -- 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 --- src/quickwidgets/qquickwidget.cpp | 3 ++ .../quickwidgets/qquickwidget/tst_qquickwidget.cpp | 33 ++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/src/quickwidgets/qquickwidget.cpp b/src/quickwidgets/qquickwidget.cpp index 49ac0caefd..2e8623f508 100644 --- a/src/quickwidgets/qquickwidget.cpp +++ b/src/quickwidgets/qquickwidget.cpp @@ -1440,6 +1440,9 @@ bool QQuickWidget::event(QEvent *e) d->offscreenWindow->setWindowState(resolveWindowState(windowState())); break; + case QEvent::ShortcutOverride: + return QCoreApplication::sendEvent(d->offscreenWindow, e); + default: break; } 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 06c0702e7e252227ca907bc3654179ad079cd1b5 Mon Sep 17 00:00:00 2001 From: Stephan Binner Date: Sat, 6 May 2017 23:04:03 +0200 Subject: Add sections and update purposes of features Change-Id: I95923fa183172bb4fe5d0a6ae34c801e0cee2a63 Reviewed-by: Oswald Buddenhagen Reviewed-by: Shawn Rutledge --- src/qml/configure.json | 9 ++++++--- src/quick/configure.json | 41 +++++++++++++++++++++++++++-------------- 2 files changed, 33 insertions(+), 17 deletions(-) diff --git a/src/qml/configure.json b/src/qml/configure.json index 2c4887365f..257bedecbc 100644 --- a/src/qml/configure.json +++ b/src/qml/configure.json @@ -15,17 +15,20 @@ "features": { "qml-interpreter": { "label": "QML interpreter", - "purpose": "Support for the QML interpreter", + "purpose": "Provides the QML interpreter.", + "section": "QML", "output": [ "privateFeature" ] }, "qml-network": { "label": "QML network support", - "purpose": "Provides network transparency for QML", + "purpose": "Provides network transparency.", + "section": "QML", "output": [ "publicFeature" ] }, "qml-profiler": { "label": "Command line QML Profiler", - "purpose": "The QML Profiler retrieves QML tracing data from an application.", + "purpose": "Supports retrieving QML tracing data from an application.", + "section": "QML", "condition": [ "features.commandlineparser", "features.localserver", diff --git a/src/quick/configure.json b/src/quick/configure.json index 047fa8c948..65ad5b810b 100644 --- a/src/quick/configure.json +++ b/src/quick/configure.json @@ -34,7 +34,8 @@ "features": { "d3d12": { "label": "Direct3D 12", - "purpose": "Provides a Direct3D 12 backend for the Qt Quick Scenegraph", + "purpose": "Provides a Direct3D 12 backend for the scenegraph.", + "section": "Qt Quick", "condition": "tests.d3d12", "output": [ "publicFeature" @@ -42,7 +43,8 @@ }, "quick-animatedimage": { "label": "AnimatedImage item", - "purpose": "Provides the Qt Quick AnimatedImage Item", + "purpose": "Provides the AnimatedImage item.", + "section": "Qt Quick", "condition": "features.movie", "output": [ "privateFeature" @@ -50,29 +52,33 @@ }, "quick-canvas": { "label": "Canvas item", - "purpose": "Provides the Qt Quick Canvas Item", + "purpose": "Provides the Canvas item.", + "section": "Qt Quick", "condition": "features.quick-path", "output": [ "privateFeature" ] }, "quick-designer": { - "label": "Support for Quick Designer", - "purpose": "Provides support for the Qt Quick Designer in Qt Creator", + "label": "Support for Qt Quick Designer", + "purpose": "Provides support for the Qt Quick Designer in Qt Creator.", + "section": "Qt Quick", "output": [ "privateFeature" ] }, "quick-flipable": { "label": "Flipable item", - "purpose": "Provides the Qt Quick Flipable Item", + "purpose": "Provides the Flipable item.", + "section": "Qt Quick", "output": [ "privateFeature" ] }, "quick-gridview": { "label": "GridView item", - "purpose": "Provides the Qt Quick GridView item", + "purpose": "Provides the GridView item.", + "section": "Qt Quick", "output": [ "privateFeature" ] @@ -93,14 +99,16 @@ }, "quick-listview": { "label": "ListView item", - "purpose": "Provides the Qt Quick ListView item", + "purpose": "Provides the ListView item.", + "section": "Qt Quick", "output": [ "privateFeature" ] }, "quick-particles": { "label": "Particle support", - "purpose": "Provides a particle system for Qt Quick", + "purpose": "Provides a particle system.", + "section": "Qt Quick", "condition": "features.quick-shadereffect && features.quick-sprite && features.opengl", "output": [ "privateFeature" @@ -108,14 +116,16 @@ }, "quick-path": { "label": "Path support", - "purpose": "Provides Path elements in Qt Quick", + "purpose": "Provides Path elements.", + "section": "Qt Quick", "output": [ "privateFeature" ] }, "quick-pathview": { "label": "PathView item", - "purpose": "Provides the Qt Quick PathView item", + "purpose": "Provides the PathView item.", + "section": "Qt Quick", "condition": "features.quick-path", "output": [ "privateFeature" @@ -123,21 +133,24 @@ }, "quick-positioners": { "label": "Positioner items", - "purpose": "Provides Positioner items in Qt Quick", + "purpose": "Provides Positioner items.", + "section": "Qt Quick", "output": [ "privateFeature" ] }, "quick-shadereffect": { "label": "ShaderEffect item", - "purpose": "Provides Shader effects in Qt Quick", + "purpose": "Provides Shader effects.", + "section": "Qt Quick", "output": [ "privateFeature" ] }, "quick-sprite": { "label": "Sprite item", - "purpose": "Provides the Qt Quick Sprite Item", + "purpose": "Provides the Sprite item.", + "section": "Qt Quick", "output": [ "privateFeature" ] -- cgit v1.2.3 From 344fbc3d2f4ccc9773e2bbe7b2969b4ac86dc9aa Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Mon, 15 May 2017 17:26:45 +0200 Subject: remove bogus QTPLUGIN+=qsqlite magic the code was originally meant to link the plugin if it's not built into qtsql. this logic did not survive the various build system refactorings, but it's also entirely pointless, because available static plugins are now automatically linked. Change-Id: I1d4f08ed5abdcc15c6b5f97bb4f6caa0a5db6f18 Reviewed-by: Simon Hausmann --- examples/quick/demos/samegame/samegame.pro | 2 -- 1 file changed, 2 deletions(-) diff --git a/examples/quick/demos/samegame/samegame.pro b/examples/quick/demos/samegame/samegame.pro index 0f01654d46..7b680490ad 100644 --- a/examples/quick/demos/samegame/samegame.pro +++ b/examples/quick/demos/samegame/samegame.pro @@ -6,5 +6,3 @@ RESOURCES += samegame.qrc target.path = $$[QT_INSTALL_EXAMPLES]/quick/demos/samegame INSTALLS += target - -!qtConfig(sql-sqlite): QTPLUGIN += qsqlite -- 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 --- src/quick/items/qquickwindow.cpp | 2 +- tests/auto/quick/qquickwindow/tst_qquickwindow.cpp | 11 ----------- 2 files changed, 1 insertion(+), 12 deletions(-) diff --git a/src/quick/items/qquickwindow.cpp b/src/quick/items/qquickwindow.cpp index ff4a357641..c441cfc357 100644 --- a/src/quick/items/qquickwindow.cpp +++ b/src/quick/items/qquickwindow.cpp @@ -3862,7 +3862,7 @@ QSGTexture *QQuickWindow::createTextureFromImage(const QImage &image) const QSGTexture *QQuickWindow::createTextureFromImage(const QImage &image, CreateTextureOptions options) const { Q_D(const QQuickWindow); - if (!isSceneGraphInitialized() || image.isNull()) // check both for d->context and d->context->isValid() + if (!isSceneGraphInitialized()) // check both for d->context and d->context->isValid() return 0; uint flags = 0; if (options & TextureCanUseAtlas) flags |= QSGRenderContext::CreateTexture_Atlas; 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 --- src/quick/items/qquickview.cpp | 1 + src/quick/items/qquickwindow.cpp | 1 + tests/auto/quick/qquickview/data/findChild.qml | 9 +++++ tests/auto/quick/qquickview/tst_qquickview.cpp | 40 ++++++++++++++++++++++ tests/auto/quick/qquickwindow/tst_qquickwindow.cpp | 24 +++++++++++++ 5 files changed, 75 insertions(+) create mode 100644 tests/auto/quick/qquickview/data/findChild.qml diff --git a/src/quick/items/qquickview.cpp b/src/quick/items/qquickview.cpp index 8313b53a7d..fca1805fc9 100644 --- a/src/quick/items/qquickview.cpp +++ b/src/quick/items/qquickview.cpp @@ -496,6 +496,7 @@ void QQuickViewPrivate::setRootObject(QObject *obj) if (QQuickItem *sgItem = qobject_cast(obj)) { root = sgItem; sgItem->setParentItem(q->QQuickWindow::contentItem()); + QQml_setParent_noEvent(sgItem, q->QQuickWindow::contentItem()); } else if (qobject_cast(obj)) { qWarning() << "QQuickView does not support using windows as a root item." << endl << endl diff --git a/src/quick/items/qquickwindow.cpp b/src/quick/items/qquickwindow.cpp index c441cfc357..d30f1c3f78 100644 --- a/src/quick/items/qquickwindow.cpp +++ b/src/quick/items/qquickwindow.cpp @@ -526,6 +526,7 @@ void QQuickWindowPrivate::init(QQuickWindow *c, QQuickRenderControl *control) Q_Q(QQuickWindow); contentItem = new QQuickRootItem; + QQml_setParent_noEvent(contentItem, c); QQmlEngine::setObjectOwnership(contentItem, QQmlEngine::CppOwnership); QQuickItemPrivate *contentItemPrivate = QQuickItemPrivate::get(contentItem); contentItemPrivate->window = q; 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 From d77587b95f490ba9be372acfb81a1659f2844b2f Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 18 Apr 2017 16:51:28 -0700 Subject: Move Q_REQUIRED_RESULT to the beginning of the declaration MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit That's the correct place and works with C++11 attributes. Change-Id: I7814054a102a407d876ffffd14b6a2f74423c222 Reviewed-by: Sérgio Martins --- src/qml/compiler/qqmlpropertyvalidator_p.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/qml/compiler/qqmlpropertyvalidator_p.h b/src/qml/compiler/qqmlpropertyvalidator_p.h index d0bd314461..e37b8141f4 100644 --- a/src/qml/compiler/qqmlpropertyvalidator_p.h +++ b/src/qml/compiler/qqmlpropertyvalidator_p.h @@ -69,8 +69,8 @@ private: bool canCoerce(int to, QQmlPropertyCache *fromMo) const; - QVector recordError(const QV4::CompiledData::Location &location, const QString &description) const Q_REQUIRED_RESULT; - QVector recordError(const QQmlCompileError &error) const Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT QVector recordError(const QV4::CompiledData::Location &location, const QString &description) const; + Q_REQUIRED_RESULT QVector recordError(const QQmlCompileError &error) const; QString stringAt(int index) const { return qmlUnit->stringAt(index); } QQmlEnginePrivate *enginePrivate; -- cgit v1.2.3 From d8f84e5769632544dfac5138348481330c4da4cd Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Tue, 23 May 2017 16:41:20 +0200 Subject: Disable ahead-of-time cache generation on Android It appears that not all phones are happy with the code that we generate. Until we can find a fix for that, let's disable the feature. Change-Id: If4aa5cc14edcb69843fb9ef32691657c8c507b83 Task-number: QTBUG-60918 Reviewed-by: Shawn Rutledge --- tools/qmlcachegen/qmlcache.prf | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tools/qmlcachegen/qmlcache.prf b/tools/qmlcachegen/qmlcache.prf index 4470db0d09..330da358b7 100644 --- a/tools/qmlcachegen/qmlcache.prf +++ b/tools/qmlcachegen/qmlcache.prf @@ -3,6 +3,11 @@ static { return() } +android { + message("QML cache generation ahead of time is not supported on Android") + return() +} + qtPrepareTool(QML_CACHEGEN, qmlcachegen, _ARCH_CHECK) isEmpty(TARGETPATH): error("Must set TARGETPATH (QML import name) for ahead-of-time QML cache generation") -- cgit v1.2.3