summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlivier Goffart <ogoffart@trolltech.com>2009-04-14 08:02:42 (GMT)
committerOlivier Goffart <ogoffart@trolltech.com>2009-04-14 12:56:39 (GMT)
commit91aeceb7132f4afae0996443a162a5783d8f17aa (patch)
treec1559e76fdcc30f132cf9283b4ebaa492d24af70
parente1a9014cc92091e8371f9a888ff94c694f562df0 (diff)
downloadQt-91aeceb7132f4afae0996443a162a5783d8f17aa.zip
Qt-91aeceb7132f4afae0996443a162a5783d8f17aa.tar.gz
Qt-91aeceb7132f4afae0996443a162a5783d8f17aa.tar.bz2
Fix crash in QTreeView
Discovered in Kopete trunk BT: yes Reviewed-by: Thierry
-rw-r--r--src/gui/itemviews/qtreeview.cpp1
-rw-r--r--tests/auto/qtreeview/tst_qtreeview.cpp26
2 files changed, 26 insertions, 1 deletions
diff --git a/src/gui/itemviews/qtreeview.cpp b/src/gui/itemviews/qtreeview.cpp
index 0117db2..62c1277 100644
--- a/src/gui/itemviews/qtreeview.cpp
+++ b/src/gui/itemviews/qtreeview.cpp
@@ -2019,6 +2019,7 @@ int QTreeView::verticalOffset() const
// If we are scrolling per item and have non-uniform row heights,
// finding the vertical offset in pixels is going to be relatively slow.
// ### find a faster way to do this
+ d->executePostedLayout();
int offset = 0;
for (int i = 0; i < d->viewItems.count(); ++i) {
if (i == verticalScrollBar()->value())
diff --git a/tests/auto/qtreeview/tst_qtreeview.cpp b/tests/auto/qtreeview/tst_qtreeview.cpp
index e1d405d..dfccd9e 100644
--- a/tests/auto/qtreeview/tst_qtreeview.cpp
+++ b/tests/auto/qtreeview/tst_qtreeview.cpp
@@ -209,6 +209,8 @@ private slots:
void indexRowSizeHint();
void addRowsWhileSectionsAreHidden();
+ void filterProxyModelCrash();
+
// task-specific tests:
void task174627_moveLeftToRoot();
void task171902_expandWith1stColHidden();
@@ -2829,6 +2831,29 @@ void tst_QTreeView::indexRowSizeHint()
QCOMPARE(view.indexRowSizeHint(index), w->sizeHint().height());
}
+void tst_QTreeView::filterProxyModelCrash()
+{
+ QStandardItemModel model;
+ QList<QStandardItem *> items;
+ for (int i = 0; i < 100; i++)
+ items << new QStandardItem(QString::fromLatin1("item %1").arg(i));
+ model.appendColumn(items);
+
+ QSortFilterProxyModel proxy;
+ proxy.setSourceModel(&model);
+
+ QTreeView view;
+ view.setModel(&proxy);
+ view.show();
+ QTest::qWait(30);
+ proxy.invalidate();
+ view.verticalScrollBar()->setValue(15);
+ QTest::qWait(20);
+
+ proxy.invalidate();
+ view.repaint(); //used to crash
+}
+
class task174627_TreeView : public QTreeView
{
Q_OBJECT
@@ -3254,6 +3279,5 @@ void tst_QTreeView::task246536_scrollbarsNotWorking()
QVERIFY(o.count > 0);
}
-
QTEST_MAIN(tst_QTreeView)
#include "tst_qtreeview.moc"