summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/gui/itemviews/qheaderview.cpp9
-rw-r--r--tests/auto/qheaderview/tst_qheaderview.cpp14
2 files changed, 17 insertions, 6 deletions
diff --git a/src/gui/itemviews/qheaderview.cpp b/src/gui/itemviews/qheaderview.cpp
index eb3db21..586e5d4 100644
--- a/src/gui/itemviews/qheaderview.cpp
+++ b/src/gui/itemviews/qheaderview.cpp
@@ -1698,13 +1698,10 @@ void QHeaderView::sectionsInserted(const QModelIndex &parent,
if (!d->sectionHidden.isEmpty()) {
QBitArray sectionHidden(d->sectionHidden);
sectionHidden.resize(sectionHidden.count() + insertCount);
- //sectionHidden.fill(false, logicalFirst, logicalLast + 1);
- for (int i = logicalFirst; i <= logicalLast; ++i)
- // visual == logical in this range (see previous block)
- sectionHidden.setBit(i, false);
+ sectionHidden.fill(false, logicalFirst, logicalLast + 1);
for (int j = logicalLast + 1; j < sectionHidden.count(); ++j)
- sectionHidden.setBit(d->visualIndex(j),
- d->sectionHidden.testBit(d->visualIndex(j - insertCount)));
+ //here we simply copy the old sectionHidden
+ sectionHidden.setBit(j, d->sectionHidden.testBit(j - insertCount));
d->sectionHidden = sectionHidden;
}
diff --git a/tests/auto/qheaderview/tst_qheaderview.cpp b/tests/auto/qheaderview/tst_qheaderview.cpp
index 4642830..f6cd4e3 100644
--- a/tests/auto/qheaderview/tst_qheaderview.cpp
+++ b/tests/auto/qheaderview/tst_qheaderview.cpp
@@ -192,6 +192,7 @@ private slots:
void task248050_hideRow();
void QTBUG6058_reset();
void QTBUG7833_sectionClicked();
+ void QTBUG8650_crashOnInsertSections();
protected:
QHeaderView *view;
@@ -2056,6 +2057,19 @@ void tst_QHeaderView::QTBUG7833_sectionClicked()
QCOMPARE(pressedSpy.at(2).at(0).toInt(), 0);
}
+void tst_QHeaderView::QTBUG8650_crashOnInsertSections()
+{
+ QStringList headerLabels;
+ QHeaderView view(Qt::Horizontal);
+ QStandardItemModel model(2,2);
+ view.setModel(&model);
+ view.moveSection(1, 0);
+ view.hideSection(0);
+
+ QList<QStandardItem *> items;
+ items << new QStandardItem("c");
+ model.insertColumn(0, items);
+}
QTEST_MAIN(tst_QHeaderView)
#include "tst_qheaderview.moc"