From f14f653580b87193bec607f56aea86a0992a21c9 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Thu, 6 Jul 2023 21:12:31 +0200 Subject: [PATCH] QSortFilterProxyModel test: fix failing appearsAndSort Testcase appearsAndSort failed when running the complete testcase but not as single test. More irritating was the fact that the error was in QAbstractItemModelTester::headerDataChanged() but the affected test did not change any header nor does it use the blamed model... The reason for this is, that QAbstractProxyModel emits a queued headerDataChanged signal when the header item count changes and therefore only evaluated when the event loop is run. Fix it by calling processEvents() after the rowCount change in filterColumns(). Amends 72e802f3b0cc7a0f36fe3c445d401d38af97ca99 Change-Id: I10cb5aa9c40a6925113cc9c23616774bf15784a4 Reviewed-by: Volker Hilsheimer (cherry picked from commit cdc608359a54a4b286494c1563f3cd94609030c0) Reviewed-by: Qt Cherry-pick Bot --- .../qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp b/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp index 2883a6df08f..2d50cc9c215 100644 --- a/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp +++ b/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp @@ -62,6 +62,7 @@ void tst_QSortFilterProxyModel::cleanup() m_proxy->sort(-1, Qt::AscendingOrder); m_model->clear(); m_model->insertColumns(0, 1); + QCoreApplication::processEvents(); // cleanup possibly queued events } /* @@ -1100,7 +1101,6 @@ void tst_QSortFilterProxyModel::filterColumns_data() << "bravo" << "lima") << true; - QTest::newRow("some") << "lie" << (QStringList() << "charlie" @@ -1126,6 +1126,7 @@ void tst_QSortFilterProxyModel::filterColumns() // prepare model m_model->setColumnCount(initial.size()); m_model->setRowCount(1); + QCoreApplication::processEvents(); // QAbstractProxyModel queues the headerDataChanged() signal QCOMPARE(m_model->columnCount(QModelIndex()), initial.size()); QCOMPARE(m_model->rowCount(QModelIndex()), 1); // set data