Merge lp:~a1s/qbrz/fix-argument-types into lp:qbrz

Proposed by Aleksandr Smyshliaev
Status: Merged
Approved by: Robert Ladyman
Approved revision: 1643
Merged at revision: 1647
Proposed branch: lp:~a1s/qbrz/fix-argument-types
Merge into: lp:qbrz
Diff against target: 163 lines (+19/-19)
6 files modified
lib/annotate.py (+6/-6)
lib/config.py (+3/-3)
lib/decorators.py (+2/-2)
lib/diffview.py (+6/-6)
lib/logwidget.py (+1/-1)
lib/revtreeview.py (+1/-1)
To merge this branch: bzr merge lp:~a1s/qbrz/fix-argument-types
Reviewer Review Type Date Requested Status
Jelmer Vernooij Approve
Review via email: mp+413803@code.launchpad.net

Commit message

Fix passing arguments of invalid type.

Description of the change

Current QBrz passes float arguments to some methods that accept only int. For example:

Traceback (most recent call last):
  File "/usr/lib/python3.10/site-packages/breezy/plugins/qbrz/lib/uifactory.py", line 32, in decorate
    r = f(*args, **kargs)
  File "/usr/lib/python3.10/site-packages/breezy/plugins/qbrz/lib/log.py", line 798, in show_diff_files
    self.log_list.show_diff(specific_files=paths, specific_file_ids=ids, ext_diff=ext_diff)
  File "/usr/lib/python3.10/site-packages/breezy/plugins/qbrz/lib/logwidget.py", line 508, in show_diff
    diff.show_diff(arg_provider, ext_diff=ext_diff,
  File "/usr/lib/python3.10/site-packages/breezy/plugins/qbrz/lib/diff.py", line 75, in show_diff
    window = DiffWindow(arg_provider, parent=parent_window)
  File "/usr/lib/python3.10/site-packages/breezy/plugins/qbrz/lib/diffwindow.py", line 138, in __init__
    self.diffview = SidebySideDiffView(self)
  File "/usr/lib/python3.10/site-packages/breezy/plugins/qbrz/lib/diffview.py", line 252, in __init__
    self.view = _SidebySideDiffView(parent)
  File "/usr/lib/python3.10/site-packages/breezy/plugins/qbrz/lib/diffview.py", line 408, in __init__
    titleFont.setPointSize(titleFont.pointSize() * 140 / 100)
TypeError: setPointSize(self, int): argument 1 has unexpected type 'float'

This change converts such arguments to integers for QTimer and QRect, and uses pointSizeF (which is float) instead of pointSize (integer) for QFont objects.

To post a comment you must log in.
Revision history for this message
Jelmer Vernooij (jelmer) :
review: Approve
lp:~a1s/qbrz/fix-argument-types updated
1643. By Aleksandr Smyshliaev

Fix syncing horizontal sliders in diffview

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/annotate.py'
2--- lib/annotate.py 2021-01-06 10:46:29 +0000
3+++ lib/annotate.py 2022-01-08 10:52:55 +0000
4@@ -153,11 +153,11 @@
5 text_margin = self.style().pixelMetric(QtWidgets.QStyle.PM_FocusFrameHMargin, None, self) + 1
6
7 if 0: rect = QtCore.QRect
8- line_number_rect = QtCore.QRect(
9+ line_number_rect = QtCore.QRect(*map(int, [
10 rect.left() + text_margin,
11 rect.top(),
12 self.line_number_width - (2 * text_margin),
13- rect.height())
14+ rect.height()]))
15
16 painter.drawText(line_number_rect, QtCore.Qt.AlignRight, str(line_number))
17
18@@ -169,21 +169,21 @@
19 font.setBold(True)
20 painter.setFont(font)
21
22- revno_rect = QtCore.QRect(
23+ revno_rect = QtCore.QRect(*map(int, [
24 rect.left() + self.line_number_width + text_margin,
25 rect.top(),
26 self.revno_width - (2 * text_margin),
27- rect.height())
28+ rect.height()]))
29 paint_revno(painter, revno_rect, str(self.get_revno(revid)), self.max_mainline_digits)
30
31 if revid in cached_revisions:
32 rev = cached_revisions[revid]
33- author_rect = QtCore.QRect(
34+ author_rect = QtCore.QRect(*map(int, [
35 rect.left() + self.line_number_width
36 + self.revno_width + text_margin,
37 rect.top(),
38 rect.right() - revno_rect.right() - (2 * text_margin),
39- rect.height())
40+ rect.height()]))
41 author = get_apparent_author_name(rev)
42 if fm.width(author) > author_rect.width():
43 author= fm.elidedText(author, QtCore.Qt.ElideRight, author_rect.width())
44
45=== modified file 'lib/config.py'
46--- lib/config.py 2021-01-05 13:03:34 +0000
47+++ lib/config.py 2022-01-08 10:52:55 +0000
48@@ -176,7 +176,7 @@
49 gettext("Command")])
50 self.extDiffList.setItemDelegateForColumn(0,
51 QRadioCheckItemDelegate(self.extDiffList))
52- self.extDiffList.itemChanged [QTreeWidgetItem, int].connect(self.extDiffListItemChanged)
53+ self.extDiffList.itemChanged [QtWidgets.QTreeWidgetItem, int].connect(self.extDiffListItemChanged)
54
55 addExtDiffButton = QtWidgets.QPushButton(gettext("Add"), diffWidget)
56 addExtDiffButton.clicked.connect(self.addExtDiff)
57@@ -205,9 +205,9 @@
58 self.merge_tools_model = MergeToolsTableModel()
59 self.merge_ui.tools.setModel(self.merge_tools_model)
60
61- self.merge_tools_model.dataChanged[QModelIndex, QModelIndex].connect(self.merge_tools_data_changed)
62+ self.merge_tools_model.dataChanged[QtCore.QModelIndex, QtCore.QModelIndex].connect(self.merge_tools_data_changed)
63
64- self.merge_ui.tools.selectionModel().selectionChanged[QItemSelection, QItemSelection].connect(self.merge_tools_selectionChanged)
65+ self.merge_ui.tools.selectionModel().selectionChanged[QtCore.QItemSelection, QtCore.QItemSelection].connect(self.merge_tools_selectionChanged)
66
67 self.merge_ui.add.clicked.connect(self.merge_tools_add_clicked)
68 self.merge_ui.remove.clicked.connect(self.merge_tools_remove_clicked)
69
70=== modified file 'lib/decorators.py'
71--- lib/decorators.py 2021-01-05 13:03:34 +0000
72+++ lib/decorators.py 2022-01-08 10:52:55 +0000
73@@ -59,7 +59,7 @@
74 elapsed = (time.time() - self._last_scheduled_at) * 1000
75 if elapsed < self.millisec:
76 # Retry
77- QtCore.QTimer.singleShot(self.millisec - elapsed, self._exec)
78+ QtCore.QTimer.singleShot(int(self.millisec - elapsed), self._exec)
79 return
80
81 last_executed_at = self._last_scheduled_at
82@@ -72,7 +72,7 @@
83 # One more call if there was another request when executing proc
84 QtCore.QTimer.singleShot(self.millisec, self._exec)
85 return
86-
87+
88 self._last_scheduled_at = 0
89
90 def lazy_call(millisec, per_instance=False):
91
92=== modified file 'lib/diffview.py'
93--- lib/diffview.py 2021-01-06 15:04:27 +0000
94+++ lib/diffview.py 2022-01-08 10:52:55 +0000
95@@ -123,7 +123,7 @@
96 pen.setWidth(2)
97 painter.setPen(pen)
98 for block_y in self.infoBlocks:
99- block_y = block_y - y
100+ block_y = int(block_y - y)
101 if block_y < top:
102 continue
103 if block_y > bot:
104@@ -132,8 +132,8 @@
105
106 pen.setWidth(1)
107 for y_top, y_bot, kind in self.changes:
108- y_top -= y
109- y_bot -= y
110+ y_top = int(y_top - y)
111+ y_bot = int(y_bot - y)
112 if y_top < top and y_bot < top:
113 continue
114 if y_top > bot and y_bot > bot:
115@@ -405,12 +405,12 @@
116 self.complete = False
117
118 titleFont = QtGui.QFont(self.font())
119- titleFont.setPointSize(titleFont.pointSize() * 140 / 100)
120+ titleFont.setPointSizeF(titleFont.pointSizeF() * 140 / 100)
121 titleFont.setBold(True)
122
123 self.monospacedFont = get_monospace_font()
124 metadataFont = QtGui.QFont(self.font())
125- metadataFont.setPointSize(titleFont.pointSize() * 70 / 100)
126+ metadataFont.setPointSizeF(titleFont.pointSizeF() * 70 / 100)
127 metadataLabelFont = QtGui.QFont(metadataFont)
128 metadataLabelFont.setBold(True)
129
130@@ -786,7 +786,7 @@
131 if m:
132 value = slider2.minimum() + slider2.maximum() * (value - slider1.minimum()) / m
133 self.ignoreUpdate = True
134- slider2.setValue(value)
135+ slider2.setValue(int(value))
136 self.ignoreUpdate = False
137
138 def syncHorizontalSlider1(self, value):
139
140=== modified file 'lib/logwidget.py'
141--- lib/logwidget.py 2021-01-08 11:30:55 +0000
142+++ lib/logwidget.py 2022-01-08 10:52:55 +0000
143@@ -706,7 +706,7 @@
144
145 finally:
146 painter.restore()
147- rect.adjust( (graphCols + 1.5) * boxsize, 0, 0, 0)
148+ rect.adjust( int((graphCols + 1.5) * boxsize), 0, 0, 0)
149
150 painter.save()
151 x = 0
152
153=== modified file 'lib/revtreeview.py'
154--- lib/revtreeview.py 2021-01-05 16:26:04 +0000
155+++ lib/revtreeview.py 2022-01-08 10:52:55 +0000
156@@ -127,7 +127,7 @@
157 # self.throbber.show()
158 # self.load_revisions_throbber_shown = True
159 # Allow for more scrolling to happen.
160- self.delay(0.5)
161+ self.delay(500)
162
163 return False
164

Subscribers

People subscribed via source and target branches