Skip to content

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

@greschd

Description

@greschd

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

  • Run the following script (adapted and minimized from the workbench example):

    from traits.etsconfig.api import ETSConfig
    ETSConfig.toolkit = 'wx'
    
    from traits.api import HasTraits, Int, Str
    from pyface.api import GUI
    from pyface.action.api import StatusBarManager
    from pyface.workbench.api import WorkbenchWindow, Workbench
    
    
    class ExampleWorkbenchWindow(WorkbenchWindow):
        def _status_bar_manager_default(self):
            return StatusBarManager(messages=['', ''])
    
    
    class Person(HasTraits):
        name = Str()
        age = Int()
    
        def __str__(self):
            return self.name
    
    if __name__ == "__main__":
        gui = GUI()
        fred = Person(name="fred", age=42)
        workbench = Workbench(state_location=gui.state_location, window_factory=ExampleWorkbenchWindow)
        window = workbench.create_window()
        window.open()
        window.edit(fred)
    
        gui.start_event_loop()
  • Close the application

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions