enthought / pyface

pyface: traits-capable windowing framework
Other
107 stars 55 forks source link

Bug report: Exception when closing a workbench with status bar #1217

Open greschd opened 1 year ago

greschd commented 1 year ago

Environment

OS: Windows Python version: 3.10 Toolkit: Wx

Description

When creating a Workbench with a status_bar, the following exception is raised when closing the window:

Traceback (most recent call last):
  File "D:\ANSYSDev\thirdparty_sources\pyface\pyface\dock\dock_sizer.py", line 4022, in CalcMin
    dx, dy = self._contents.calc_min()
  File "D:\ANSYSDev\thirdparty_sources\pyface\pyface\dock\dock_sizer.py", line 3190, in calc_min
    dx, dy = item.calc_min(use_size)
  File "D:\ANSYSDev\thirdparty_sources\pyface\pyface\dock\dock_sizer.py", line 2402, in calc_min
    theme = self.theme
  File "D:\ANSYSDev\thirdparty_sources\pyface\pyface\dock\dock_sizer.py", line 503, in _get_theme
    return self.control.GetParent().owner.theme
RuntimeError: wrapped C/C++ object of type TraitsUIPanel has been deleted

Steps to Reproduce

Other observations

The exception does not occur if the window tab (fred) is closed before closing the Application.

Changing the toolkit to 'qt' also makes the exception disappear.

greschd commented 1 year ago

A crude way to get rid of the error is by removing

https://github.com/enthought/pyface/blob/85fd54431983b6472eab5e341b139a9b53f150a9/pyface/i_application_window.py#L132-L133

added in #1141. I suspect this is not the correct solution though, and #1141 simply exposed the underlying issue.

corranwebster commented 1 year ago

Possibly related to this recent PR: https://github.com/enthought/pyface/pull/1192

greschd commented 1 year ago

Directly reverting #1192 (and passing self.control as parent) doesn't fix the issue, but it might indeed be related to why parent was maybe used at some earlier point.

Also note: I've noticed this particular repro doesn't produce an error on Linux, but have seen the same error in a more complex application. If desired, I can try and find a version that fails on both platforms.

corranwebster commented 1 year ago

I have a hypothesis that this is because the status bar is not being removed from the owning window before it is destroyed.