aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/quick/items/qquickdrag.cpp2
-rw-r--r--tests/auto/quick/qquickdrag/tst_qquickdrag.cpp25
2 files changed, 26 insertions, 1 deletions
diff --git a/src/quick/items/qquickdrag.cpp b/src/quick/items/qquickdrag.cpp
index a900406b17..a2cb739ff2 100644
--- a/src/quick/items/qquickdrag.cpp
+++ b/src/quick/items/qquickdrag.cpp
@@ -442,7 +442,7 @@ void QQuickDragAttached::setImageSource(const QUrl &url)
if (url.isEmpty()) {
d->pixmapLoader.clear();
} else {
- d->pixmapLoader.load(qmlEngine(this), url);
+ d->pixmapLoader.load(qmlEngine(parent()), url);
}
Q_EMIT imageSourceChanged();
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)