Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Layout extraction error when closing application with undocked panes. #374

Open
sparsonslab opened this issue Nov 30, 2020 · 0 comments
Open

Comments

@sparsonslab
Copy link

sparsonslab commented Nov 30, 2020

We have an application with instances of pyface.tasks.api.DockPane.

When one of these DockPanes is undocked from the main window and then the app is closed, we get the following traceback:

2020-11-30 09:29:19,075 ERROR    [traits:221] Exception occurred in traits notification handler for object: <envisage.ui.tasks.task_window.TaskWindow object at 0x7fa8a79223b8>, trait: closing, old value: <undefined>, new value: <traits.has_traits.Vetoable object at 0x7fa88a537830>
Traceback (most recent call last):
  File "/Users/sparsons/.edm/envs/dev/lib/python3.6/site-packages/traits/trait_notifiers.py", line 522, in _dispatch_change_event
    self.dispatch(handler, *args)
  File "/Users/sparsons/.edm/envs/dev/lib/python3.6/site-packages/traits/trait_notifiers.py", line 484, in dispatch
    handler(*args)
  File "/Users/sparsons/.edm/envs/dev/lib/python3.6/site-packages/envisage/ui/tasks/tasks_application.py", line 479, in _on_window_closing
    window_layout = window.get_window_layout()
  File "/Users/sparsons/.edm/envs/dev/lib/python3.6/site-packages/pyface/tasks/task_window.py", line 312, in get_window_layout
    layout = self._window_backend.get_layout()
  File "/Users/sparsons/.edm/envs/dev/lib/python3.6/site-packages/pyface/ui/qt4/tasks/task_window_backend.py", line 92, in get_layout
    self._main_window_layout.get_layout(layout)
  File "/Users/sparsons/.edm/envs/dev/lib/python3.6/site-packages/pyface/ui/qt4/tasks/main_window_layout.py", line 58, in get_layout
    sublayout = self.get_layout_for_area(q_dock_area, include_sizes)
  File "/Users/sparsons/.edm/envs/dev/lib/python3.6/site-packages/pyface/ui/qt4/tasks/main_window_layout.py", line 132, in get_layout_for_area
    "Unable to extract layout from QMainWindow."
RuntimeError: Unable to extract layout from QMainWindow.

It seems that when the when the app is closed (envisage.ui.tasks.tasks_application.TasksApplication._on_window_closing) it tries to get the window layout for saving (pyface.ui.qt4.tasks.main_window_layout.MainWindowLayout.get_layout_for_area) but this throws an error, presumably because the undocked pane is not found.

As the app is closing anyway, it has no harmful effects, but it is a bit off-putting to get a RuntimeError. A band-aid might be to catch the error at TasksApplication._on_window_closing (or force docking of panes before getting the layout ?).

I put this as an Envisage issue, rather than Pyface, as it has its root at envisage.ui.tasks.tasks_application.TasksApplication._on_window_closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants