Skip to content

Commit

Permalink
Fix dock pane undocking (#1044)
Browse files Browse the repository at this point in the history
* Fix error when undocking a dock pane.

* Ignore undocked panes when getting area changes.

* Add a test that undocking doesn't crash.

* Remove extra imports.

* Update pyface/ui/qt4/tasks/dock_pane.py

Co-authored-by: Poruri Sai Rahul <[email protected]>

* Remove print statement.

Co-authored-by: Poruri Sai Rahul <[email protected]>
  • Loading branch information
corranwebster and Poruri Sai Rahul authored Dec 20, 2021
1 parent f29e668 commit 82ab911
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pyface/ui/qt4/tasks/dock_pane.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,8 @@ def _set_visible(self, event):

def _receive_dock_area(self, area):
with self._signal_context():
self.dock_area = INVERSE_AREA_MAP[int(area)]
if int(area) in INVERSE_AREA_MAP:
self.dock_area = INVERSE_AREA_MAP[int(area)]

def _receive_floating(self, floating):
with self._signal_context():
Expand Down
25 changes: 25 additions & 0 deletions pyface/ui/qt4/tasks/tests/test_dock_pane.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ def _task_factories_default(self):


class TestDockPane(unittest.TestCase):

@unittest.skipUnless(sys.platform == "darwin", "only applicable to macOS")
def test_dock_windows_visible_on_macos(self):
# Regression test for enthought/pyface#427: check that dock panes
Expand All @@ -75,3 +76,27 @@ def check_panes_and_exit(app_event):
self.assertTrue(tool_attributes)
for attr in tool_attributes:
self.assertTrue(attr)

def test_dock_windows_undock(self):
# Regression test for enthought/pyface#1028: check that undocking
# dockpanes doesn't crash

tool_attributes = []

def check_panes_and_exit(app_event):
app = app_event.application
app.windows[0].dock_panes[0].control.setFloating(True)
for window in app.windows:
for dock_pane in window.dock_panes:
attr = dock_pane.dock_area
tool_attributes.append(attr)

app.exit()

app = MyApplication()
app.on_trait_change(check_panes_and_exit, "application_initialized")
app.run()

self.assertTrue(tool_attributes)
for attr in tool_attributes:
self.assertEqual(attr, 'left')

0 comments on commit 82ab911

Please sign in to comment.