diff --git a/src/quick/items/qquickrepeater.cpp b/src/quick/items/qquickrepeater.cpp
index 35e37d12463f81fce170489f45b7ae3bb7e6a599..bf6d3c495bf4ce1af525c895cb32daefa0379e84 100644
--- a/src/quick/items/qquickrepeater.cpp
+++ b/src/quick/items/qquickrepeater.cpp
@@ -217,7 +217,7 @@ void QQuickRepeater::setModel(const QVariant &model)
             d->model = new QQmlDelegateModel(qmlContext(this));
             d->ownModel = true;
             if (isComponentComplete())
-                static_cast<QQmlDelegateModel *>(d->model)->componentComplete();
+                static_cast<QQmlDelegateModel *>(d->model.data())->componentComplete();
         }
         if (QQmlDelegateModel *dataModel = qobject_cast<QQmlDelegateModel*>(d->model))
             dataModel->setModel(model);
@@ -329,7 +329,7 @@ void QQuickRepeater::componentComplete()
 {
     Q_D(QQuickRepeater);
     if (d->model && d->ownModel)
-        static_cast<QQmlDelegateModel *>(d->model)->componentComplete();
+        static_cast<QQmlDelegateModel *>(d->model.data())->componentComplete();
     QQuickItem::componentComplete();
     regenerate();
     if (d->model && d->model->count())
diff --git a/src/quick/items/qquickrepeater_p_p.h b/src/quick/items/qquickrepeater_p_p.h
index f220eb4fcb874afb2b647e52c0fa759703c7804e..a642f6479a61c5d6abc01b9aa03e9cd528df9cac 100644
--- a/src/quick/items/qquickrepeater_p_p.h
+++ b/src/quick/items/qquickrepeater_p_p.h
@@ -73,7 +73,7 @@ public:
 private:
     void createItems();
 
-    QQmlInstanceModel *model;
+    QPointer<QQmlInstanceModel> model;
     QVariant dataSource;
     QQmlGuard<QObject> dataSourceAsObject;
     bool ownModel : 1;
diff --git a/tests/auto/quick/qquickrepeater/data/visualitemmodel.qml b/tests/auto/quick/qquickrepeater/data/visualitemmodel.qml
new file mode 100644
index 0000000000000000000000000000000000000000..b1b7b9788135b01ccb1fe7910a93816baccf9807
--- /dev/null
+++ b/tests/auto/quick/qquickrepeater/data/visualitemmodel.qml
@@ -0,0 +1,23 @@
+import QtQuick 2.0
+
+Rectangle {
+    width: 360
+    height: 360
+
+    VisualItemModel {
+        id: visItemModel
+        Rectangle {
+            width: 20
+            height: 20
+            color: "red"
+        }
+    }
+
+    Column {
+        anchors.fill: parent
+        Repeater {
+            model: visItemModel
+        }
+    }
+}
+
diff --git a/tests/auto/quick/qquickrepeater/tst_qquickrepeater.cpp b/tests/auto/quick/qquickrepeater/tst_qquickrepeater.cpp
index 582503f93864b4af1613ca4f2fa54ede7950a32e..9fb76f958437fd72fe6752f74cbaba3fdfa01ee1 100644
--- a/tests/auto/quick/qquickrepeater/tst_qquickrepeater.cpp
+++ b/tests/auto/quick/qquickrepeater/tst_qquickrepeater.cpp
@@ -78,6 +78,7 @@ private slots:
     void asynchronous();
     void initParent();
     void dynamicModelCrash();
+    void visualItemModelCrash();
 };
 
 class TestObject : public QObject
@@ -732,6 +733,17 @@ void tst_QQuickRepeater::dynamicModelCrash()
     QVERIFY(qvariant_cast<QObject *>(repeater->model()) == 0);
 }
 
+void tst_QQuickRepeater::visualItemModelCrash()
+{
+    // This used to crash because the model would get
+    // deleted before the repeater, leading to double-deletion
+    // of the items.
+    QQuickView *window = createView();
+    window->setSource(testFileUrl("visualitemmodel.qml"));
+    qApp->processEvents();
+    delete window;
+}
+
 QTEST_MAIN(tst_QQuickRepeater)
 
 #include "tst_qquickrepeater.moc"