diff --git a/newsfragments/1538.bugfix.rst b/newsfragments/1538.bugfix.rst new file mode 100644 index 00000000000..73d050b068c --- /dev/null +++ b/newsfragments/1538.bugfix.rst @@ -0,0 +1 @@ +Fixed crash on MacOS when closing a dialog diff --git a/parsec/core/gui/custom_dialogs.py b/parsec/core/gui/custom_dialogs.py index 2e8be1bc7e0..acfdd012fe7 100644 --- a/parsec/core/gui/custom_dialogs.py +++ b/parsec/core/gui/custom_dialogs.py @@ -105,7 +105,11 @@ def on_finished(self): ): getattr(self.center_widget, "on_close")() self.closing.emit() - self.setParent(None) + # On Windows, GreyedDialogs don't get cleared out if their parent + # is not set to None. Linux seems to clear them automatically over time. + # Resetting the parent on MacOS causes a crash. + if platform.system() != "Darwin": + self.setParent(None) class TextInputWidget(QWidget, Ui_InputWidget): @@ -264,7 +268,7 @@ def toggle_details(self, checked): def show_error(parent, message, exception=None): w = ErrorWidget(message, exception) d = GreyedDialog(w, title=_("TEXT_ERR_DIALOG_TITLE"), parent=parent) - return d.exec_() + return d.open() class InfoWidget(QWidget, Ui_InfoWidget): @@ -292,4 +296,4 @@ def show_info(parent, message, button_text=None): d = GreyedDialog(w, title=None, parent=parent, hide_close=True) w.dialog = d w.button_ok.setFocus() - return d.exec_() + return d.open() diff --git a/tests/core/gui/conftest.py b/tests/core/gui/conftest.py index 4b84d4ee1c8..a2f24211863 100644 --- a/tests/core/gui/conftest.py +++ b/tests/core/gui/conftest.py @@ -232,6 +232,9 @@ def _dialog_exec(dialog): monkeypatch.setattr( "parsec.core.gui.custom_dialogs.GreyedDialog.exec_", _dialog_exec, raising=False ) + monkeypatch.setattr( + "parsec.core.gui.custom_dialogs.GreyedDialog.open", _dialog_exec, raising=False + ) return spy