I've read in several places that its not safe to rely on constructors for types derived from Blender objects, such as property groups. But now I am creating a pop-up window with an operator class (using
context.window_manager.invoke_props_dialog()), and I need to execute code when the window is opened and closed.
Previously, I was using
invoke() as my open event, and
execute() as my closing event. But I just found out that
execute() is only called when the "OK" button is pressed. If the user clicks outside of the window to unfocus the window, it closes without executing. I'm assuming this is basically "cancel", which is cool. But I still want to execute certain code when it happens, if possible.
I've tried implementing
__del__(self) for the operator window, and they both appear to be called when the window opens and closes. But its difficult to know how reliable the behavior will be. Can anyone confirm that it is safe to use these as open/close events for an operator window? Or is there a better way to handle it?