diff options
author | Fabian Kosmale <fabian.kosmale@qt.io> | 2019-10-29 16:11:21 +0100 |
---|---|---|
committer | Fabian Kosmale <fabian.kosmale@qt.io> | 2019-10-30 09:17:36 +0100 |
commit | 234dbbf25567ce44a8c8e099d003f04a12f2b371 (patch) | |
tree | 36e30d7b49c1e1ee854d3054fd18a0a025388dd9 /tests/auto/quick/qquickdrag | |
parent | cdf00b076ee8934598fa6cd1af01f83e80ac73e0 (diff) |
QML Drag: Prevent crash when using image provider url
For attached property objects, qmlEngine will not return an engine.
However, QQuickDragAttached's parent is the object to which it is
attached, and from that one we can get the engine.
Fixes: QTBUG-72045
Change-Id: I40748dd11ea3eb4604c37e932b2cfd3baad6fd1f
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'tests/auto/quick/qquickdrag')
-rw-r--r-- | tests/auto/quick/qquickdrag/tst_qquickdrag.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/auto/quick/qquickdrag/tst_qquickdrag.cpp b/tests/auto/quick/qquickdrag/tst_qquickdrag.cpp index 9d832066af..d3d3505e85 100644 --- a/tests/auto/quick/qquickdrag/tst_qquickdrag.cpp +++ b/tests/auto/quick/qquickdrag/tst_qquickdrag.cpp @@ -143,6 +143,7 @@ private slots: void source(); void recursion_data(); void recursion(); + void noCrashWithImageProvider(); private: QQmlEngine engine; @@ -1279,6 +1280,30 @@ void tst_QQuickDrag::recursion() } } +void tst_QQuickDrag::noCrashWithImageProvider() +{ + // QTBUG-72045 + QQmlComponent component(&engine); + component.setData( + R"( + import QtQuick 2.9 + Item { + Rectangle { + id: item + width: 50 + height: 50 + anchors.centerIn: parent + color: "orange" + Component.onCompleted: { + item.Drag.imageSource = "image://kill/me" + } + } + })", QUrl()); + QScopedPointer<QObject> object(component.create()); + QQuickItem *item = qobject_cast<QQuickItem *>(object.data()); + QVERIFY(item); +} + QTEST_MAIN(tst_QQuickDrag) |