diff options
author | Olivier Goffart <ogoffart@trolltech.com> | 2010-03-01 15:57:30 (GMT) |
---|---|---|
committer | Olivier Goffart <ogoffart@trolltech.com> | 2010-03-01 16:02:42 (GMT) |
commit | d6910f12cdaac746b0b336cb0d8b9b4ea830e9e2 (patch) | |
tree | 56eb2ecdc48aa96a8096f8d7a7c004725c7ea5f1 /tests/auto/qtableview | |
parent | 65f993d679140fb2dc29b48c9d9d8d2fc5af893d (diff) | |
download | Qt-d6910f12cdaac746b0b336cb0d8b9b4ea830e9e2.zip Qt-d6910f12cdaac746b0b336cb0d8b9b4ea830e9e2.tar.gz Qt-d6910f12cdaac746b0b336cb0d8b9b4ea830e9e2.tar.bz2 |
Fix crash using openPersistentEditor and setRowHidden on a QTableView
Hiding widget might result in focus changes that will modify the list
of editors while iterating over it.
Same fixe as in commit 386726f7184cc77f0692e2ba24d85ebc53a39569
The test comes from the Task
Task-number: QTBUG-8585
Reviewed-by: Thierry
Diffstat (limited to 'tests/auto/qtableview')
-rw-r--r-- | tests/auto/qtableview/tst_qtableview.cpp | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/tests/auto/qtableview/tst_qtableview.cpp b/tests/auto/qtableview/tst_qtableview.cpp index 430712c..a5cbbd4 100644 --- a/tests/auto/qtableview/tst_qtableview.cpp +++ b/tests/auto/qtableview/tst_qtableview.cpp @@ -199,6 +199,7 @@ private slots: void taskQTBUG_5062_spansInconsistency(); void taskQTBUG_4516_clickOnRichTextLabel(); void taskQTBUG_5237_wheelEventOnHeader(); + void taskQTBUG_8585_crashForNoGoodReason(); void mouseWheel_data(); void mouseWheel(); @@ -3948,5 +3949,50 @@ void tst_QTableView::taskQTBUG_5237_wheelEventOnHeader() QVERIFY(sbValueBefore != sbValueAfter); } +class TestTableView : public QTableView { +Q_OBJECT +public: + TestTableView(QWidget *parent = 0) : QTableView(parent) + { + connect(this, SIGNAL(entered(const QModelIndex&)), this, SLOT(openEditor(const QModelIndex&))); + } + ~TestTableView(){} +public slots: + void onDataChanged() + { + for (int i = 0; i < model()->rowCount(); i++) { + setRowHidden(i, model()->data(model()->index(i, 0)).toBool()); + } + } + + void openEditor(const QModelIndex& index) + { openPersistentEditor(index); } +}; + + +void tst_QTableView::taskQTBUG_8585_crashForNoGoodReason() +{ + QStandardItemModel model; + model.insertColumn(0, QModelIndex()); + for(int i = 0; i < 20; i++) + { + model.insertRow(i); + } + + TestTableView w; + w.setMouseTracking(true); + w.setModel(&model); + connect(&model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), &w, SLOT(onDataChanged())); + w.show(); + QTest::qWaitForWindowShown(&w); + for (int i = 0; i < 10; i++) + { + QTest::mouseMove(w.viewport(), QPoint(50, 20)); + w.model()->setData(w.indexAt(QPoint(50, 20)), true); + QTest::mouseMove(w.viewport(), QPoint(50, 25)); + } +} + + QTEST_MAIN(tst_QTableView) #include "tst_qtableview.moc" |