Trolltech task ID : 236454 bugs.kde.org number : 176045 applied: no author: Olivier Goffart This patch makes sure no deleted items are being accessed during an animation of the treeview It will also be contained in the upcoming Qt snapshots --- a/src/gui/itemviews/qtreeview.cpp +++ b/src/gui/itemviews/qtreeview.cpp @@ -2815,10 +2815,9 @@ void QTreeViewPrivate::expand(int item, q->setState(oldState); if (emitSignal) { + emit q->expanded(index); if (animationsEnabled) beginAnimatedOperation(); - else - emit q->expanded(index); } if (model->canFetchMore(index)) model->fetchMore(index); @@ -2858,10 +2857,9 @@ void QTreeViewPrivate::collapse(int item q->setState(oldState); if (emitSignal) { + emit q->collapsed(modelIndex); if (animationsEnabled) beginAnimatedOperation(); - else - emit q->collapsed(modelIndex); } _q_forceColumnResizeToFitContents(); @@ -2918,10 +2916,6 @@ void QTreeViewPrivate::_q_endAnimatedOpe animatedOperation.before = QPixmap(); animatedOperation.after = QPixmap(); q->setState(QAbstractItemView::NoState); - if (animatedOperation.type == AnimatedOperation::Expand) - emit q->expanded(viewItems.at(animatedOperation.item).index); - else // operation == AnimatedOperation::Collapse - emit q->collapsed(viewItems.at(animatedOperation.item).index); q->updateGeometries(); viewport->update(); }