diff options
author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2023-01-02 17:41:50 +0100 |
---|---|---|
committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2023-01-04 13:42:06 +0100 |
commit | fb8701cb8b1972d5ca6ffc383a436786bc170d16 (patch) | |
tree | 39ce15217f73359ded121f0e98a63dd2286dce26 /tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp | |
parent | 84a68ef75ce8a8e5b90d799c90905cc998c7c2f6 (diff) |
QListView: Prevent infinite loop when wrapping text of item with null-icon
If an item in a list view has a null icon, then the decorationSize gets
calculated as -1, -1. The style would then try to wrap the text to a
lineWidth of -1, ending up in an infinite loop in viewItemTextLayout.
To prevent that, don't set the HasDecoration flag of the style option
when the icon is null, and don't fall back ot the decorationSize unless
the flag is set.
Add a test for this particular item configuration. This also fixes the
widget baseline test with styles that don't provide all standard icons.
Pick-to: 6.5
Change-Id: I691db6abede9a9b2ad300f3ee7fbfdae5fb6097f
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Reviewed-by: Santhosh Kumar <santhosh.kumar.selvaraj@qt.io>
Diffstat (limited to 'tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp')
-rw-r--r-- | tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp b/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp index 3c43b3fcd5..c7bd1c934a 100644 --- a/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp +++ b/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp @@ -156,6 +156,7 @@ private slots: void spacingWithWordWrap(); void scrollOnRemove_data(); void scrollOnRemove(); + void wordWrapNullIcon(); }; // Testing get/set functions @@ -3174,6 +3175,22 @@ void tst_QListView::scrollOnRemove() QTRY_COMPARE(view.verticalScrollBar()->value(), item25Position); } +void tst_QListView::wordWrapNullIcon() +{ + QListView listView; + listView.setViewMode(QListView::IconMode); + listView.setWrapping(true); + listView.setWordWrap(true); + listView.setFixedSize(QSize(100, 500)); + + QStandardItemModel model; + QStandardItem *item = new QStandardItem(QIcon(), "This is a long text for word wrapping Item_"); + model.appendRow(item); + listView.setModel(&model); + + listView.indexAt(QPoint(0, 0)); +} + QTEST_MAIN(tst_QListView) #include "tst_qlistview.moc" |