From 28b894f65c5aba01d5ee80c20f617478faaee7e7 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Wed, 19 May 2010 10:58:11 +0200 Subject: Fix a memory leak from QItemSelectionModel when changing the model Reviewed-By: ogoffart Task-Number: QTBUG-10806 --- src/gui/itemviews/qabstractitemview.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/gui/itemviews/qabstractitemview.cpp b/src/gui/itemviews/qabstractitemview.cpp index 97fd6e1..064f499 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 } -- cgit v0.12