tst_QWidget: Improve diagnostic output in cleanup()

Use QTRY_COMPARE to have the size of topLevelWidgets() in logs.
Add a warning if QApplication::allWidgets() isn't empty.

Task-number: QTBUG-135138
Change-Id: I40bc3e5054776cb1b751218d9b9d1c46b349ccc7
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
This commit is contained in:
Axel Spoerl 2025-03-25 10:24:42 +01:00
parent 62153d6ce0
commit 91c60f25e0

View File

@ -725,7 +725,9 @@ void tst_QWidget::initTestCase()
void tst_QWidget::cleanup()
{
QTRY_VERIFY(QApplication::topLevelWidgets().isEmpty());
QTRY_COMPARE(QApplication::topLevelWidgets(), QWidgetList());
if (!QApplication::allWidgets().isEmpty())
qWarning() << "Test function has leaked" << QApplication::allWidgets();
}
template <typename T>