Skip to content

Commit c9f0367

Browse files
More maintenance backports. (#1151)
* Fixes from investigating #1117 (#1149) * Only delete attribute if it exists. * Use correct full name for MiddleButton. * Extract bytes rather than use QByteArray * Add test for SplitTabWeidget mouseReleaseEvent. * Remove unused imports. * Fix test and original middle button code. * Update changelog.
1 parent f1ffad4 commit c9f0367

File tree

6 files changed

+39
-9
lines changed

6 files changed

+39
-9
lines changed

CHANGES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ Thanks to:
2626

2727
Fixes
2828

29+
* fixes for Qt workbench backend (#1149)
2930
* fix ConsoleWidget PySide6 issues (#1146, #1147)
3031
* fix default AboutDialog image (#1142)
3132
* remove reference cycle for actions on clean-up (#1143)

pyface/ui/qt4/action/action_item.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,8 @@ def _qt4_on_destroyed(self, control=None):
376376
"""
377377
if self.control is not None:
378378
# Remove the cycle since we're no longer needed.
379-
del self.control._tool_instance
379+
if hasattr(self.control, "_tool_instance"):
380+
del self.control._tool_instance
380381
self.control = None
381382

382383
def _qt4_on_triggered(self):

pyface/ui/qt4/workbench/split_tab_widget.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -998,7 +998,7 @@ def mouseReleaseEvent(self, e):
998998
QtGui.QTabBar.mouseReleaseEvent(self, e)
999999

10001000
if e.button() != QtCore.Qt.MouseButton.LeftButton:
1001-
if e.button() == QtCore.Qt.MidddleButton:
1001+
if e.button() == QtCore.Qt.MouseButton.MiddleButton:
10021002
self.tabCloseRequested.emit(self.tabAt(e.pos()))
10031003
return
10041004

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# (C) Copyright 2005-2022 Enthought, Inc., Austin, TX
2+
# All rights reserved.
3+
#
4+
# This software is provided without warranty under the terms of the BSD
5+
# license included in LICENSE.txt and may be redistributed only under
6+
# the conditions described in the aforementioned license. The license
7+
# is also available online at http://www.enthought.com/licenses/BSD.txt
8+
#
9+
# Thanks for using Enthought open source!
10+
11+
12+
import unittest
13+
14+
from pyface.qt import QtCore, QtGui
15+
from pyface.ui.qt4.workbench.split_tab_widget import _DragableTabBar
16+
17+
18+
class TestSplitTabWidget(unittest.TestCase):
19+
20+
def test_mouseReleaseEvent(self):
21+
widget = _DragableTabBar(None, None)
22+
event = QtGui.QMouseEvent(
23+
QtCore.QEvent.Type.MouseButtonRelease,
24+
QtCore.QPointF(0.0, 0.0),
25+
QtCore.QPointF(0.0, 0.0),
26+
QtCore.Qt.MouseButton.RightButton,
27+
QtCore.Qt.RightButton,
28+
QtCore.Qt.NoModifier,
29+
)
30+
31+
# smoke test: should do nothing
32+
widget.mouseReleaseEvent(event)
33+
34+
widget.destroy()

pyface/ui/qt4/workbench/tests/test_workbench_window_layout.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
# Thanks for using Enthought open source!
1010

1111

12-
import sys
1312
import unittest
1413
from unittest import mock
1514

@@ -21,12 +20,8 @@
2120

2221
class TestWorkbenchWindowLayout(unittest.TestCase):
2322

24-
@unittest.skipIf(sys.version_info == (3, 8), "Can't mock SplitTabWidget")
2523
def test_change_of_active_qt_editor(self):
2624
# Test error condition for enthought/mayavi#321
27-
28-
# This doesn't work on Python 3.8 because of some incompatibility
29-
# between unittest.mock.Mock and Qt, I think
3025
mock_split_tab_widget = mock.Mock(spec=SplitTabWidget)
3126

3227
layout = WorkbenchWindowLayout(_qt4_editor_area=mock_split_tab_widget)

pyface/ui/qt4/workbench/workbench_window_layout.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,7 @@ def get_view_memento(self):
203203
view_ids = [v.id for v in self.window.views if self.contains_view(v)]
204204

205205
# Everything else is provided by QMainWindow.
206-
state = self.window.control.saveState()
207-
206+
state = self.window.control.saveState().data()
208207
return (0, (view_ids, state))
209208

210209
def set_view_memento(self, memento):

0 commit comments

Comments
 (0)