Skip to content

Commit

Permalink
Merge pull request #1539 from Scille/gui-fix-crash-macos
Browse files Browse the repository at this point in the history
[GUI] Fixed crash on MacOS when resetting a greyed dialog parent
  • Loading branch information
Max-7 committed Nov 3, 2020
2 parents 5db9aec + fb6bdd3 commit b6aad68
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions newsfragments/1538.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed crash on MacOS when closing a dialog
10 changes: 7 additions & 3 deletions parsec/core/gui/custom_dialogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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()
3 changes: 3 additions & 0 deletions tests/core/gui/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down

0 comments on commit b6aad68

Please sign in to comment.