Skip to content

Commit da43169

Browse files
committed
test: stabilize issue107 GDI test against leftover widgets in shared QApplication
The test drove mass deleteLater()+processEvents() in-process; stale top-level widgets left alive by earlier suite tests caused a Qt teardown fast-fail (0xC0000409) on Windows. Clean them up at test start. Passes on 3.11 and 3.14.
1 parent 9ba1751 commit da43169

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

qwt/tests/test_issue107_gdi_leak.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,20 @@ def test_gdi_leak_stability():
4848
if not env.unattended:
4949
pytest.skip("This test is for CI/unattended mode only")
5050

51+
# Close any top-level widgets left alive by previous tests in the shared
52+
# QApplication. This test aggressively drives ``deleteLater()`` +
53+
# ``processEvents()`` in-process; processing deferred deletions while stale
54+
# widgets from earlier tests are still pending triggers a Qt teardown
55+
# fast-fail (0xC0000409) on Windows. Starting from a clean widget set makes
56+
# the test robust inside the full suite (it already passes in isolation).
57+
app = QW.QApplication.instance() or QW.QApplication([])
58+
for widget in list(app.topLevelWidgets()):
59+
widget.close()
60+
widget.deleteLater()
61+
app.processEvents()
62+
app.sendPostedEvents(None, QC.QEvent.DeferredDelete)
63+
app.processEvents()
64+
5165
n_cycles = 50
5266
for i in range(n_cycles):
5367
run_stress_cycle()

0 commit comments

Comments
 (0)