path: root/sources
diff options
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2017-07-27 11:40:08 +0200
committerSimo Fält <simo.falt@qt.io>2017-07-27 12:12:15 +0000
commit9d4fd1b6526911e2836e84e45f67315968b1a117 (patch)
treeb4f254fae29e7e7ed0e7618929e6149d906443a2 /sources
parentaac61d9e35374aa4a309aaa2110f0bf6f67a598b (diff)
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 <alexandru.croitor@qt.io>
Diffstat (limited to 'sources')
1 files changed, 16 insertions, 1 deletions
diff --git a/sources/pyside2/tests/QtWidgets/bug_728.py b/sources/pyside2/tests/QtWidgets/bug_728.py
index 8ef40b37..d2783b74 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()
# 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)