From f365f0e5cdfa20ebae68414d410c0cee8764d53b Mon Sep 17 00:00:00 2001 From: Pierre Raybaut Date: Tue, 21 Nov 2023 13:21:43 +0100 Subject: [PATCH] `close_widgets_and_quit`: ignore deleted widgets --- guidata/qthelpers.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/guidata/qthelpers.py b/guidata/qthelpers.py index 6d4a834..093be87 100644 --- a/guidata/qthelpers.py +++ b/guidata/qthelpers.py @@ -448,7 +448,11 @@ def close_widgets_and_quit(screenshot: bool = False) -> None: screenshot (bool): If True, save a screenshot of each widget """ for widget in QW.QApplication.instance().topLevelWidgets(): - wname = widget.objectName() + try: + wname = widget.objectName() + except RuntimeError: + # Widget has been deleted + continue if screenshot and wname and widget.isVisible(): # pragma: no cover grab_save_window(widget, wname.lower()) assert widget.close()