diff options
author | Thierry Bastian <thierry.bastian@nokia.com> | 2010-05-19 08:58:11 (GMT) |
---|---|---|
committer | Thierry Bastian <thierry.bastian@nokia.com> | 2010-05-19 08:58:11 (GMT) |
commit | 28b894f65c5aba01d5ee80c20f617478faaee7e7 (patch) | |
tree | f88c342191f71f179be803bd8a4f0900efbb054a /src/gui/itemviews | |
parent | 9547ade2b9cd7c792d98bf06ca8de89c9e560396 (diff) | |
download | Qt-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/gui/itemviews')
-rw-r--r-- | src/gui/itemviews/qabstractitemview.cpp | 6 |
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 } |