From 3c7e7992461b1fef37ada68244f1b5b891015bda Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Mon, 26 Jul 2010 20:51:32 +0200 Subject: Fix crash when all the items in a QListView are hidden Calling QIconModeViewBase::initDynamicLayout() on the second and successive segments would return QPoint(-1,-1), resulting in a totally empty area rectangle for all the items while in QIconModeViewBase::doDynamicLayout(). This rectangle is used to initialize the BSP tree, and produces an arithmetic exception when empty. Furthermore, a rendering bug was also apparent when displaying the first item of a segment while the last item of the previous segment was hidden. Auto-tests included. Reviewed-by: Olivier Task-number: QTBUG-12308 --- src/gui/itemviews/qlistview.cpp | 7 ++++- tests/auto/qlistview/tst_qlistview.cpp | 51 ++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+), 1 deletion(-) diff --git a/src/gui/itemviews/qlistview.cpp b/src/gui/itemviews/qlistview.cpp index b2def39..64ae0db 100644 --- a/src/gui/itemviews/qlistview.cpp +++ b/src/gui/itemviews/qlistview.cpp @@ -2773,7 +2773,10 @@ QPoint QIconModeViewBase::initDynamicLayout(const QListViewLayoutInfo &info) y = info.bounds.y() + info.spacing; items.reserve(rowCount() - hiddenCount()); } else { - const QListViewItem item = items.at(info.first - 1); + int idx = info.first - 1; + while (idx > 0 && !items.at(idx).isValid()) + --idx; + const QListViewItem &item = items.at(idx); x = item.x; y = item.y; if (info.flow == QListView::LeftToRight) @@ -2899,6 +2902,8 @@ void QIconModeViewBase::doDynamicLayout(const QListViewLayoutInfo &info) // resize the content area if (done || !info.bounds.contains(item->rect())) contentsSize = QSize(rect.width(), rect.height()); + if (rect.size().isEmpty()) + return; // resize tree int insertFrom = info.first; if (done || info.first == 0) { diff --git a/tests/auto/qlistview/tst_qlistview.cpp b/tests/auto/qlistview/tst_qlistview.cpp index d2181f8..e5b42ce 100644 --- a/tests/auto/qlistview/tst_qlistview.cpp +++ b/tests/auto/qlistview/tst_qlistview.cpp @@ -45,6 +45,7 @@ #include #include #include +#include #include #include #include @@ -123,6 +124,8 @@ private slots: void taskQTBUG_435_deselectOnViewportClick(); void taskQTBUG_2678_spacingAndWrappedText(); void taskQTBUG_5877_skippingItemInPageDownUp(); + void taskQTBUG_12308_artihmeticException(); + void taskQTBUG_12308_wrongFlowLayout(); }; // Testing get/set functions @@ -1941,5 +1944,53 @@ void tst_QListView::taskQTBUG_5877_skippingItemInPageDownUp() } } +void tst_QListView::taskQTBUG_12308_artihmeticException() +{ + QListWidget lw; + lw.setLayoutMode(QListView::Batched); + lw.setViewMode(QListView::IconMode); + for (int i = 0; i < lw.batchSize() + 1; i++) { + QListWidgetItem *item = new QListWidgetItem(); + item->setText(QString("Item %L1").arg(i)); + lw.addItem(item); + item->setHidden(true); + } + lw.show(); + QTest::qWaitForWindowShown(&lw); + // No crash, it's all right. +} + +class Delegate12308 : public QStyledItemDelegate +{ + Q_OBJECT +public: + Delegate12308(QObject *parent = 0) : QStyledItemDelegate(parent) + { } + + void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const + { + QVERIFY(option.rect.topLeft() != QPoint(-1, -1)); + QStyledItemDelegate::paint(painter, option, index); + } +}; + +void tst_QListView::taskQTBUG_12308_wrongFlowLayout() +{ + QListWidget lw; + Delegate12308 delegate; + lw.setLayoutMode(QListView::Batched); + lw.setViewMode(QListView::IconMode); + lw.setItemDelegate(&delegate); + for (int i = 0; i < lw.batchSize() + 1; i++) { + QListWidgetItem *item = new QListWidgetItem(); + item->setText(QString("Item %L1").arg(i)); + lw.addItem(item); + if (!item->text().contains(QString::fromAscii("1"))) + item->setHidden(true); + } + lw.show(); + QTest::qWaitForWindowShown(&lw); +} + QTEST_MAIN(tst_QListView) #include "tst_qlistview.moc" -- cgit v0.12 onverter Mirror from: https://github.com/HDFGroup/hdf5.git
summaryrefslogtreecommitdiffstats
path: root/src
Commit message (Expand)AuthorAgeFilesLines
* Correct usage of MPI varsAllen Byrne2017-11-011-6/+4
* Convert to use MPI:: for linkAllen Byrne2017-11-011-2/+4
* Correct command usageAllen Byrne2017-11-011-5/+5
* Change MPI target properties for libraryAllen Byrne2017-11-011-2/+2
* Add a missing declaration for testingRichard Warren2017-10-271-0/+1
* Moved the SWMR + cache image check up before the root groupDana Robinson2017-10-211-15/+8
* Moved the 'cache image + SWMR' check from H5Fcreate/open to H5F_open.Dana Robinson2017-10-192-18/+18
* Merge pull request #704 in HDFFV/hdf5 from optimize_superblock_read to developRichard Warren2017-10-131-43/+90
|\
| * Try to address most of the issues raised by Dana in the code reviewRichard Warren2017-10-111-51/+51
| * Add a test for parallel reads of independent files using MPI subgroupsRichard Warren2017-10-092-34/+7
| * Edits to the file open optimization and associated testmainzer2017-10-052-11/+38
| * Merge branch 'develop' of https://bitbucket.hdfgroup.org/scm/hdffv/hdf5 into ...Richard Warren2017-09-2811-43/+65
| |\
| * | The initial coding for the superblock read optizationRichard Warren2017-09-282-2/+49
* | | HDFFV-10297 update calls to H5Zfilter_availAllen Byrne2017-10-091-1/+2
* | | HDFFV-10297 - fix repack individual objectsAllen Byrne2017-10-062-233/+222
* | | Whitespace conversions and comment updatesAllen Byrne2017-10-041-535/+382
* | | Better segregate clean & dirty LRU lists so that they are only defined whenQuincey Koziol2017-09-305-0/+16
| |/ |/|
* | Style cleanups and misc. bugfixes discovered during full SWMR development.Quincey Koziol2017-09-2311-43/+65
|/
* Restore previousAllen Byrne2017-09-191-1/+1
* Generate headers for 1.10 should default offAllen Byrne2017-09-121-1/+1
* Revert malloc's back to using hard-coded type for sizeofJordan Henderson2017-09-011-23/+23
* Minor comment refactoringJordan Henderson2017-09-011-3/+4
* Update documentationJordan Henderson2017-08-311-39/+158
* Merging in latest from upstream (HDFFV/hdf5:refs/heads/develop)Jordan Henderson2017-08-246-453/+455
|\
| * Fix for daily test failureVailin Choi2017-08-241-1/+1
| * Modifications based on comments from pull request reviewVailin Choi2017-08-234-47/+26
| * Fix for HDFFV-10216 segfault in H5G_node_cmp3 with corrupt h5 fileVailin Choi2017-08-226-415/+438
* | Updated H5C__flush_single_entry() in H5C.c to correctmainzer2017-08-151-8/+18
* | Merge branch 'develop' of https://bitbucket.hdfgroup.org/scm/hdffv/hdf5 into ...Jordan Henderson2017-08-1122-888/+2362
|\ \ | |/
| * Moved H5PL diagnostic pragmas to comply with old gcc requirements that theyDana Robinson2017-08-022-17/+19
| * Minor tweaks in response to code review.Dana Robinson2017-08-011-6/+2
| * Merge branch 'develop' into h5pl_commitDana Robinson2017-08-014-19/+24
| |\
| | * Skip test in test/fheap.c when:Vailin Choi2017-07-181-1/+1
| | * Changes made based on RFC review commentsVailin Choi2017-07-184-18/+23
| * | Major rework of H5PL package code before bringing VOL changesDana Robinson2017-07-1413-817/+1856
| |/
| * Merge pull request #596 in HDFFV/hdf5 from GreaterThan-2GB-MPIO to developRichard Warren2017-07-131-46/+458
| |\
| | * Include code fixes and additional modifications pointed out by code reviewersRichard Warren2017-07-101-6/+6
| | * Commited changes to the development branch here to allow a pull request to be...Richard Warren2017-07-051-46/+458
| * | Fix for HDFFV-10217 infinite loop in H5VM_power2up().Vailin Choi2017-07-104-6/+26
| |/
* | Fix bug where incorrect amount of data was being read from the fileJordan Henderson2017-08-101-1/+1
* | Add test file to build processJordan Henderson2017-08-031-1/+1
* | Suggested changes from code reviewJordan Henderson2017-07-075-12/+60
* | Amend header comment errorJordan Henderson2017-07-061-19/+18
* | Clean up remaining warningsJordan Henderson2017-07-061-6/+21
* | Add prototype for H5D__cmp_filtered_collective_io_info_entry_ownerJordan Henderson2017-07-051-0/+2
* | Add comment for memory copy possibly not being necessary anymore forJordan Henderson2017-07-051-0/+1
* | Remove use of H5E_CANTDISTRIBUTE errorJordan Henderson2017-07-052-2/+1
* | Add comment for full overwrite special caseJordan Henderson2017-07-051-0/+8
* | Add remaining documentation/commentsJordan Henderson2017-07-051-23/+54
* | Merging in latest from upstream (HDFFV/hdf5:refs/heads/develop)Jordan Henderson2017-07-05