Change how dialogs are deleted

This commit is contained in:
Veronica Berglyd Olsen
2024-05-28 21:16:40 +02:00
parent b01a2f5abd
commit 019dd3e478
18 changed files with 27 additions and 18 deletions
+9
View File
@@ -45,6 +45,15 @@ if TYPE_CHECKING: # pragma: no cover
class NDialog(QDialog):
def softDelete(self) -> None:
"""Since calling deleteLater is sometimes not safe from Python,
as the C++ object can be deleted before the Python process is
done with the object, we instead set the dialog's parent to None
so that it gets garbage collected when it runs out of scope.
"""
self.setParent(None) # type: ignore
return
def keyPressEvent(self, event: QKeyEvent) -> None:
"""Overload keyPressEvent and forward escape to close."""
if event.matches(QKeySequence.StandardKey.Cancel):