summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@digia.com>2014-05-05 10:59:56 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-05-07 19:17:30 +0200
commit6d76e943dab0971d376cebb15fe531efc60622ac (patch)
tree80db887d580738caf19ea94b8e1b18fdb4ac8c2c /tests
parent60caef8b5874b87c270d4055fe26b34440805ca8 (diff)
Fix visual index lookup in QTreeViewPrivate::adjustViewOptionsForIndex().
Determine the visual index by looking up the column of the QModelIndex in the logicalIndices array instead of looping. Task-number: QTBUG-37813 Change-Id: I5c3c73c67537877b03cdc2c36a52041d99f7f49d Reviewed-by: David Faure <david.faure@kdab.com> (cherry picked from qtbase/85aef2dd4b059d2ba9cba4605d9fef87f3e2c4fc)
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qtreeview/tst_qtreeview.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/auto/qtreeview/tst_qtreeview.cpp b/tests/auto/qtreeview/tst_qtreeview.cpp
index c80d04c68e..64196f0a52 100644
--- a/tests/auto/qtreeview/tst_qtreeview.cpp
+++ b/tests/auto/qtreeview/tst_qtreeview.cpp
@@ -249,6 +249,7 @@ private slots:
void taskQTBUG_11466_keyboardNavigationRegression();
void taskQTBUG_13567_removeLastItemRegression();
void taskQTBUG_25333_adjustViewOptionsForIndex();
+ void taskQTBUG_37813_crash();
#ifndef QT_NO_ANIMATION
void quickExpandCollapse();
@@ -4092,5 +4093,31 @@ void tst_QTreeView::quickExpandCollapse()
#endif
+void tst_QTreeView::taskQTBUG_37813_crash()
+{
+ // QTBUG_37813: Crash in visual / logical index mapping in QTreeViewPrivate::adjustViewOptionsForIndex()
+ // when hiding/moving columns. It is reproduceable with a QTreeWidget only.
+#ifdef QT_BUILD_INTERNAL
+ QTreeWidget treeWidget;
+ treeWidget.setDragEnabled(true);
+ treeWidget.setColumnCount(2);
+ QList<QTreeWidgetItem *> items;
+ for (int r = 0; r < 2; ++r) {
+ QTreeWidgetItem *item = new QTreeWidgetItem();
+ for (int c = 0; c < treeWidget.columnCount(); ++c)
+ item->setText(c, QString::fromLatin1("Row %1 Column %2").arg(r).arg(c));
+ items.append(item);
+ }
+ treeWidget.addTopLevelItems(items);
+ treeWidget.setColumnHidden(0, true);
+ treeWidget.header()->moveSection(0, 1);
+ QItemSelection sel(treeWidget.model()->index(0, 0), treeWidget.model()->index(0, 1));
+ QRect rect;
+ QAbstractItemViewPrivate *av = static_cast<QAbstractItemViewPrivate*>(qt_widget_private(&treeWidget));
+ const QPixmap pixmap = av->renderToPixmap(sel.indexes(), &rect);
+ QVERIFY(pixmap.size().isValid());
+#endif // QT_BUILD_INTERNAL
+}
+
QTEST_MAIN(tst_QTreeView)
#include "tst_qtreeview.moc"