enthought / enthought/envisage

Layout extraction error when closing application with undocked panes.

Open
#374 0 comments 0 reactions 0 assignees View on GitHub
type: bug
Dominant language
Python
Stars
89
Forks
27
Avg merge
14h 48m
Merged PRs (30d)
7

Description

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

When one of these `DockPane`s 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: , trait: closing, old value: , new value:
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`.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start at envisage.ui.tasks.tasks_application.TasksApplication._on_window_closing and follow its call to pyface.ui.qt4.tasks.main_window_layout.MainWindowLayout.get_layout_for_area. Reproduce the failure with an undocked pyface.tasks.api.DockPane, then verify that closing the application no longer raises the layout-extraction RuntimeError.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
desktop
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.