diff options
| -rw-r--r-- | src/quick/items/qquickitem.cpp | 7 | ||||
| -rw-r--r-- | tests/auto/qml/qqmlecmascript/data/updateCall.qml | 10 | ||||
| -rw-r--r-- | tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp | 12 |
3 files changed, 28 insertions, 1 deletions
diff --git a/src/quick/items/qquickitem.cpp b/src/quick/items/qquickitem.cpp index 55ba25c63f..c11bf904be 100644 --- a/src/quick/items/qquickitem.cpp +++ b/src/quick/items/qquickitem.cpp @@ -3827,7 +3827,12 @@ void QQuickItem::setBaselineOffset(qreal offset) void QQuickItem::update() { Q_D(QQuickItem); - Q_ASSERT(flags() & ItemHasContents); + if (!(flags() & ItemHasContents)) { +#ifndef QT_NO_DEBUG + qWarning() << metaObject()->className() << ": Update called for a item without content"; +#endif + return; + } d->dirty(QQuickItemPrivate::Content); } diff --git a/tests/auto/qml/qqmlecmascript/data/updateCall.qml b/tests/auto/qml/qqmlecmascript/data/updateCall.qml new file mode 100644 index 0000000000..341a360d25 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/updateCall.qml @@ -0,0 +1,10 @@ +import QtQuick 2.1
+
+Rectangle {
+ MouseArea {
+ anchors.fill: parent;
+ Component.onCompleted: {
+ update();
+ }
+ }
+}
diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp index 52791cdee5..95f03d2c5b 100644 --- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp +++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp @@ -304,6 +304,7 @@ private slots: void propertyOverride(); void concatenatedStringPropertyAccess(); void jsOwnedObjectsDeletedOnEngineDestroy(); + void updateCall(); void numberParsing(); void stringParsing(); void qtbug_32801(); @@ -7278,6 +7279,17 @@ void tst_qqmlecmascript::jsOwnedObjectsDeletedOnEngineDestroy() delete object; } +void tst_qqmlecmascript::updateCall() +{ + // update is a slot on QQuickItem. Even though it's not + // documented it can be called from within QML. Make sure + // we don't crash when calling it. + QString file("updateCall.qml"); + QQmlComponent component(&engine, testFileUrl(file)); + QObject *object = component.create(); + QVERIFY(object != 0); +} + void tst_qqmlecmascript::numberParsing() { for (int i = 1; i < 8; ++i) { |
