Change how dialogs are deleted
This commit is contained in:
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user