From ebaaff84fc0355d2e026da7f5ca015280b2c7d82 Mon Sep 17 00:00:00 2001 From: Jiewen Wang Date: Thu, 31 May 2012 08:20:49 -0400 Subject: Eliminate QTreeWidget drag crash In QTreeViewPrivate::adjustViewOptionsForIndex() wrong index had been used when referencing to array of viewItems. Variable row is set to the index of the QModelIndex, however it is not as same as the index in viewItems[] when there was hidden item in treeWidget. Index of viewItems[] should be used here. Unit test is added as well. Change-Id: Ie129cb63445bf1239ef7c5b2bc61b04dd9e81982 Task-Id: QTBUG-25333 Backport of <3be6ca3ee8c2c72f85b26a57538fd329ed811261> from Qt5 Reviewed-by: Girish Ramakrishnan --- src/gui/itemviews/qtreeview.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gui/itemviews') diff --git a/src/gui/itemviews/qtreeview.cpp b/src/gui/itemviews/qtreeview.cpp index 1a8a686154..ffd1ad0c77 100644 --- a/src/gui/itemviews/qtreeview.cpp +++ b/src/gui/itemviews/qtreeview.cpp @@ -1357,7 +1357,7 @@ QItemViewPaintPairs QTreeViewPrivate::draggablePaintPairs(const QModelIndexList void QTreeViewPrivate::adjustViewOptionsForIndex(QStyleOptionViewItemV4 *option, const QModelIndex ¤t) const { - const int row = current.row(); + const int row = viewIndex(current); // get the index in viewItems[] option->state = option->state | (viewItems.at(row).expanded ? QStyle::State_Open : QStyle::State_None) | (viewItems.at(row).hasChildren ? QStyle::State_Children : QStyle::State_None) | (viewItems.at(row).hasMoreSiblings ? QStyle::State_Sibling : QStyle::State_None); -- cgit v1.2.3