Merge "Fix the crashes when animated QTreeWidgetItems are hidden"
This commit is contained in:
commit
d2d957ff67
@ -1486,7 +1486,8 @@ void QTreeViewPrivate::adjustViewOptionsForIndex(QStyleOptionViewItem *option, c
|
|||||||
void QTreeView::drawTree(QPainter *painter, const QRegion ®ion) const
|
void QTreeView::drawTree(QPainter *painter, const QRegion ®ion) const
|
||||||
{
|
{
|
||||||
Q_D(const QTreeView);
|
Q_D(const QTreeView);
|
||||||
const QList<QTreeViewItem> viewItems = d->viewItems;
|
// d->viewItems changes when posted layouts are executed in itemDecorationAt, so don't copy
|
||||||
|
const QList<QTreeViewItem> &viewItems = d->viewItems;
|
||||||
|
|
||||||
QStyleOptionViewItem option;
|
QStyleOptionViewItem option;
|
||||||
initViewItemOption(&option);
|
initViewItemOption(&option);
|
||||||
@ -3484,6 +3485,7 @@ int QTreeViewPrivate::indentationForItem(int item) const
|
|||||||
|
|
||||||
int QTreeViewPrivate::itemHeight(int item) const
|
int QTreeViewPrivate::itemHeight(int item) const
|
||||||
{
|
{
|
||||||
|
Q_ASSERT(item < viewItems.count());
|
||||||
if (uniformRowHeights)
|
if (uniformRowHeights)
|
||||||
return defaultItemHeight;
|
return defaultItemHeight;
|
||||||
if (viewItems.isEmpty())
|
if (viewItems.isEmpty())
|
||||||
|
@ -250,6 +250,7 @@ private slots:
|
|||||||
void taskQTBUG_7232_AllowUserToControlSingleStep();
|
void taskQTBUG_7232_AllowUserToControlSingleStep();
|
||||||
void taskQTBUG_8376();
|
void taskQTBUG_8376();
|
||||||
void taskQTBUG_61476();
|
void taskQTBUG_61476();
|
||||||
|
void taskQTBUG_42469_crash();
|
||||||
void testInitialFocus();
|
void testInitialFocus();
|
||||||
void fetchUntilScreenFull();
|
void fetchUntilScreenFull();
|
||||||
void expandAfterTake();
|
void expandAfterTake();
|
||||||
@ -5070,6 +5071,29 @@ void tst_QTreeView::taskQTBUG_61476()
|
|||||||
QCOMPARE(lastTopLevel->checkState(), Qt::Checked);
|
QCOMPARE(lastTopLevel->checkState(), Qt::Checked);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void tst_QTreeView::taskQTBUG_42469_crash()
|
||||||
|
{
|
||||||
|
QTreeWidget treeWidget;
|
||||||
|
QTreeWidgetItem *itemOne = new QTreeWidgetItem(QStringList("item1"));
|
||||||
|
QTreeWidgetItem *itemTwo = new QTreeWidgetItem(QStringList("item2"));
|
||||||
|
treeWidget.addTopLevelItem(itemOne);
|
||||||
|
treeWidget.addTopLevelItem(itemTwo);
|
||||||
|
treeWidget.topLevelItem(1)->addChild(new QTreeWidgetItem(QStringList("child1")));
|
||||||
|
|
||||||
|
treeWidget.setAnimated(true);
|
||||||
|
QObject::connect(&treeWidget, &QTreeWidget::itemExpanded, [&](QTreeWidgetItem* p_item) {
|
||||||
|
auto tempCount = treeWidget.topLevelItemCount();
|
||||||
|
for (int j = 0; j < tempCount; ++j)
|
||||||
|
if (treeWidget.topLevelItem(j) != p_item) {
|
||||||
|
auto temp = treeWidget.topLevelItem(j);
|
||||||
|
temp->setHidden(true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
treeWidget.show();
|
||||||
|
itemTwo->setExpanded(true);
|
||||||
|
}
|
||||||
|
|
||||||
void tst_QTreeView::fetchUntilScreenFull()
|
void tst_QTreeView::fetchUntilScreenFull()
|
||||||
{
|
{
|
||||||
class TreeModel : public QAbstractItemModel
|
class TreeModel : public QAbstractItemModel
|
||||||
|
Loading…
x
Reference in New Issue
Block a user