summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorThierry Bastian <thierry.bastian@nokia.com>2010-05-19 08:58:11 (GMT)
committerThierry Bastian <thierry.bastian@nokia.com>2010-05-19 08:58:11 (GMT)
commit28b894f65c5aba01d5ee80c20f617478faaee7e7 (patch)
treef88c342191f71f179be803bd8a4f0900efbb054a /src
parent9547ade2b9cd7c792d98bf06ca8de89c9e560396 (diff)
downloadQt-28b894f65c5aba01d5ee80c20f617478faaee7e7.zip
Qt-28b894f65c5aba01d5ee80c20f617478faaee7e7.tar.gz
Qt-28b894f65c5aba01d5ee80c20f617478faaee7e7.tar.bz2
Fix a memory leak from QItemSelectionModel when changing the model
Reviewed-By: ogoffart Task-Number: QTBUG-10806
Diffstat (limited to 'src')
-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 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
}