From 82934f11e06f1b1c4084c8fd4bac2e1787f0042a Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Tue, 8 Apr 2014 23:38:00 +0200 Subject: Stabilize tst_QListWidget Replace weird QEventLoop hacks by sending all posted deferred delete events. Change-Id: I6da743f2b3fb6ef5dfc960dd3d752973cd511037 Reviewed-by: Friedemann Kleint --- .../widgets/itemviews/qlistwidget/tst_qlistwidget.cpp | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp b/tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp index 153144db63..e02ab0064c 100644 --- a/tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp +++ b/tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the test suite of the Qt Toolkit. @@ -43,7 +43,6 @@ #include #include #include -#include #include #include @@ -209,14 +208,7 @@ void tst_QListWidget::cleanupTestCase() void tst_QListWidget::init() { testWidget->clear(); - - if (testWidget->viewport()->children().count() > 0) { - QEventLoop eventLoop; - for (int i=0; i < testWidget->viewport()->children().count(); ++i) - connect(testWidget->viewport()->children().at(i), SIGNAL(destroyed()), &eventLoop, SLOT(quit())); - QTimer::singleShot(100, &eventLoop, SLOT(quit())); - eventLoop.exec(); - } + QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); } void tst_QListWidget::checkDefaultValues() @@ -317,12 +309,7 @@ void tst_QListWidget::closePersistentEditor() // actual test childCount = testWidget->viewport()->children().count(); testWidget->closePersistentEditor(item); - // Spin the event loop and hopefully it will die. - QEventLoop eventLoop; - for (int i=0; i < childCount; ++i) - connect(testWidget->viewport()->children().at(i), SIGNAL(destroyed()), &eventLoop, SLOT(quit())); - QTimer::singleShot(100, &eventLoop, SLOT(quit())); - eventLoop.exec(); + QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); QCOMPARE(testWidget->viewport()->children().count(), childCount - 1); } -- cgit v1.2.3