summaryrefslogtreecommitdiffstats
path: root/src/gui/itemviews/qabstractitemview.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/itemviews/qabstractitemview.cpp')
-rw-r--r--src/gui/itemviews/qabstractitemview.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/gui/itemviews/qabstractitemview.cpp b/src/gui/itemviews/qabstractitemview.cpp
index 6d4562a..4fb93fc 100644
--- a/src/gui/itemviews/qabstractitemview.cpp
+++ b/src/gui/itemviews/qabstractitemview.cpp
@@ -679,7 +679,11 @@ void QAbstractItemView::setModel(QAbstractItemModel *model)
connect(d->model, SIGNAL(modelReset()), this, SLOT(reset()));
connect(d->model, SIGNAL(layoutChanged()), this, SLOT(_q_layoutChanged()));
}
- setSelectionModel(new QItemSelectionModel(d->model, this));
+
+ QItemSelectionModel *selection_model = new QItemSelectionModel(d->model, this);
+ connect(d->model, SIGNAL(destroyed()), selection_model, SLOT(deleteLater()));
+ setSelectionModel(selection_model);
+
reset(); // kill editors, set new root and do layout
}