From 9d4fd1b6526911e2836e84e45f67315968b1a117 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 27 Jul 2017 11:40:08 +0200 Subject: Stabilize QtWidgets bug_728.py Add a timer periodically checking for the dialog to appear and close it via reject() instead of using a hardcoded interval to quit the application, which can cause crashes. Task-number: PYSIDE-431 Change-Id: I35db1db5f6865d196f8565c7bd034de2162bf4ff Reviewed-by: Alexandru Croitor --- sources/pyside2/tests/QtWidgets/bug_728.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'sources') diff --git a/sources/pyside2/tests/QtWidgets/bug_728.py b/sources/pyside2/tests/QtWidgets/bug_728.py index 8ef40b374..d2783b746 100644 --- a/sources/pyside2/tests/QtWidgets/bug_728.py +++ b/sources/pyside2/tests/QtWidgets/bug_728.py @@ -29,8 +29,23 @@ from PySide2.QtWidgets import * from PySide2.QtCore import * +# Periodically check for the file dialog to appear and close it +dialog = None +def timerHandler(): + global dialog + if dialog is not None: + dialog.reject() + else: + for widget in QApplication.topLevelWidgets(): + if isinstance(widget, QDialog) and widget.isVisible(): + dialog = widget + app = QApplication([]) -QTimer.singleShot(200, app.quit) +QTimer.singleShot(30000, app.quit) # emergency +timer = QTimer() +timer.setInterval(50) +timer.timeout.connect(timerHandler) +timer.start() # This test for a dead lock in QFileDialog.getOpenFileNames, the test fail with a timeout if the dead lock exists. QFileDialog.getOpenFileNames(None, "caption", QDir.homePath(), None, "", QFileDialog.DontUseNativeDialog) -- cgit v1.2.3