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
=== modified file 'lib/annotate.py'
--- lib/annotate.py 2021-01-06 10:46:29 +0000
+++ lib/annotate.py 2022-01-08 10:52:55 +0000
@@ -153,11 +153,11 @@
153 text_margin = self.style().pixelMetric(QtWidgets.QStyle.PM_FocusFrameHMargin, None, self) + 1153 text_margin = self.style().pixelMetric(QtWidgets.QStyle.PM_FocusFrameHMargin, None, self) + 1
154154
155 if 0: rect = QtCore.QRect155 if 0: rect = QtCore.QRect
156 line_number_rect = QtCore.QRect(156 line_number_rect = QtCore.QRect(*map(int, [
157 rect.left() + text_margin,157 rect.left() + text_margin,
158 rect.top(),158 rect.top(),
159 self.line_number_width - (2 * text_margin),159 self.line_number_width - (2 * text_margin),
160 rect.height())160 rect.height()]))
161161
162 painter.drawText(line_number_rect, QtCore.Qt.AlignRight, str(line_number))162 painter.drawText(line_number_rect, QtCore.Qt.AlignRight, str(line_number))
163163
@@ -169,21 +169,21 @@
169 font.setBold(True)169 font.setBold(True)
170 painter.setFont(font)170 painter.setFont(font)
171171
172 revno_rect = QtCore.QRect(172 revno_rect = QtCore.QRect(*map(int, [
173 rect.left() + self.line_number_width + text_margin,173 rect.left() + self.line_number_width + text_margin,
174 rect.top(),174 rect.top(),
175 self.revno_width - (2 * text_margin),175 self.revno_width - (2 * text_margin),
176 rect.height())176 rect.height()]))
177 paint_revno(painter, revno_rect, str(self.get_revno(revid)), self.max_mainline_digits)177 paint_revno(painter, revno_rect, str(self.get_revno(revid)), self.max_mainline_digits)
178178
179 if revid in cached_revisions:179 if revid in cached_revisions:
180 rev = cached_revisions[revid]180 rev = cached_revisions[revid]
181 author_rect = QtCore.QRect(181 author_rect = QtCore.QRect(*map(int, [
182 rect.left() + self.line_number_width182 rect.left() + self.line_number_width
183 + self.revno_width + text_margin,183 + self.revno_width + text_margin,
184 rect.top(),184 rect.top(),
185 rect.right() - revno_rect.right() - (2 * text_margin),185 rect.right() - revno_rect.right() - (2 * text_margin),
186 rect.height())186 rect.height()]))
187 author = get_apparent_author_name(rev)187 author = get_apparent_author_name(rev)
188 if fm.width(author) > author_rect.width():188 if fm.width(author) > author_rect.width():
189 author= fm.elidedText(author, QtCore.Qt.ElideRight, author_rect.width())189 author= fm.elidedText(author, QtCore.Qt.ElideRight, author_rect.width())
190190
=== modified file 'lib/config.py'
--- lib/config.py 2021-01-05 13:03:34 +0000
+++ lib/config.py 2022-01-08 10:52:55 +0000
@@ -176,7 +176,7 @@
176 gettext("Command")])176 gettext("Command")])
177 self.extDiffList.setItemDelegateForColumn(0,177 self.extDiffList.setItemDelegateForColumn(0,
178 QRadioCheckItemDelegate(self.extDiffList))178 QRadioCheckItemDelegate(self.extDiffList))
179 self.extDiffList.itemChanged [QTreeWidgetItem, int].connect(self.extDiffListItemChanged)179 self.extDiffList.itemChanged [QtWidgets.QTreeWidgetItem, int].connect(self.extDiffListItemChanged)
180180
181 addExtDiffButton = QtWidgets.QPushButton(gettext("Add"), diffWidget)181 addExtDiffButton = QtWidgets.QPushButton(gettext("Add"), diffWidget)
182 addExtDiffButton.clicked.connect(self.addExtDiff)182 addExtDiffButton.clicked.connect(self.addExtDiff)
@@ -205,9 +205,9 @@
205 self.merge_tools_model = MergeToolsTableModel()205 self.merge_tools_model = MergeToolsTableModel()
206 self.merge_ui.tools.setModel(self.merge_tools_model)206 self.merge_ui.tools.setModel(self.merge_tools_model)
207207
208 self.merge_tools_model.dataChanged[QModelIndex, QModelIndex].connect(self.merge_tools_data_changed)208 self.merge_tools_model.dataChanged[QtCore.QModelIndex, QtCore.QModelIndex].connect(self.merge_tools_data_changed)
209209
210 self.merge_ui.tools.selectionModel().selectionChanged[QItemSelection, QItemSelection].connect(self.merge_tools_selectionChanged)210 self.merge_ui.tools.selectionModel().selectionChanged[QtCore.QItemSelection, QtCore.QItemSelection].connect(self.merge_tools_selectionChanged)
211211
212 self.merge_ui.add.clicked.connect(self.merge_tools_add_clicked)212 self.merge_ui.add.clicked.connect(self.merge_tools_add_clicked)
213 self.merge_ui.remove.clicked.connect(self.merge_tools_remove_clicked)213 self.merge_ui.remove.clicked.connect(self.merge_tools_remove_clicked)
214214
=== modified file 'lib/decorators.py'
--- lib/decorators.py 2021-01-05 13:03:34 +0000
+++ lib/decorators.py 2022-01-08 10:52:55 +0000
@@ -59,7 +59,7 @@
59 elapsed = (time.time() - self._last_scheduled_at) * 100059 elapsed = (time.time() - self._last_scheduled_at) * 1000
60 if elapsed < self.millisec:60 if elapsed < self.millisec:
61 # Retry61 # Retry
62 QtCore.QTimer.singleShot(self.millisec - elapsed, self._exec)62 QtCore.QTimer.singleShot(int(self.millisec - elapsed), self._exec)
63 return63 return
6464
65 last_executed_at = self._last_scheduled_at65 last_executed_at = self._last_scheduled_at
@@ -72,7 +72,7 @@
72 # One more call if there was another request when executing proc72 # One more call if there was another request when executing proc
73 QtCore.QTimer.singleShot(self.millisec, self._exec)73 QtCore.QTimer.singleShot(self.millisec, self._exec)
74 return74 return
75 75
76 self._last_scheduled_at = 076 self._last_scheduled_at = 0
7777
78def lazy_call(millisec, per_instance=False):78def lazy_call(millisec, per_instance=False):
7979
=== modified file 'lib/diffview.py'
--- lib/diffview.py 2021-01-06 15:04:27 +0000
+++ lib/diffview.py 2022-01-08 10:52:55 +0000
@@ -123,7 +123,7 @@
123 pen.setWidth(2)123 pen.setWidth(2)
124 painter.setPen(pen)124 painter.setPen(pen)
125 for block_y in self.infoBlocks:125 for block_y in self.infoBlocks:
126 block_y = block_y - y126 block_y = int(block_y - y)
127 if block_y < top:127 if block_y < top:
128 continue128 continue
129 if block_y > bot:129 if block_y > bot:
@@ -132,8 +132,8 @@
132132
133 pen.setWidth(1)133 pen.setWidth(1)
134 for y_top, y_bot, kind in self.changes:134 for y_top, y_bot, kind in self.changes:
135 y_top -= y135 y_top = int(y_top - y)
136 y_bot -= y136 y_bot = int(y_bot - y)
137 if y_top < top and y_bot < top:137 if y_top < top and y_bot < top:
138 continue138 continue
139 if y_top > bot and y_bot > bot:139 if y_top > bot and y_bot > bot:
@@ -405,12 +405,12 @@
405 self.complete = False405 self.complete = False
406406
407 titleFont = QtGui.QFont(self.font())407 titleFont = QtGui.QFont(self.font())
408 titleFont.setPointSize(titleFont.pointSize() * 140 / 100)408 titleFont.setPointSizeF(titleFont.pointSizeF() * 140 / 100)
409 titleFont.setBold(True)409 titleFont.setBold(True)
410410
411 self.monospacedFont = get_monospace_font()411 self.monospacedFont = get_monospace_font()
412 metadataFont = QtGui.QFont(self.font())412 metadataFont = QtGui.QFont(self.font())
413 metadataFont.setPointSize(titleFont.pointSize() * 70 / 100)413 metadataFont.setPointSizeF(titleFont.pointSizeF() * 70 / 100)
414 metadataLabelFont = QtGui.QFont(metadataFont)414 metadataLabelFont = QtGui.QFont(metadataFont)
415 metadataLabelFont.setBold(True)415 metadataLabelFont.setBold(True)
416416
@@ -786,7 +786,7 @@
786 if m:786 if m:
787 value = slider2.minimum() + slider2.maximum() * (value - slider1.minimum()) / m787 value = slider2.minimum() + slider2.maximum() * (value - slider1.minimum()) / m
788 self.ignoreUpdate = True788 self.ignoreUpdate = True
789 slider2.setValue(value)789 slider2.setValue(int(value))
790 self.ignoreUpdate = False790 self.ignoreUpdate = False
791791
792 def syncHorizontalSlider1(self, value):792 def syncHorizontalSlider1(self, value):
793793
=== modified file 'lib/logwidget.py'
--- lib/logwidget.py 2021-01-08 11:30:55 +0000
+++ lib/logwidget.py 2022-01-08 10:52:55 +0000
@@ -706,7 +706,7 @@
706706
707 finally:707 finally:
708 painter.restore()708 painter.restore()
709 rect.adjust( (graphCols + 1.5) * boxsize, 0, 0, 0)709 rect.adjust( int((graphCols + 1.5) * boxsize), 0, 0, 0)
710710
711 painter.save()711 painter.save()
712 x = 0712 x = 0
713713
=== modified file 'lib/revtreeview.py'
--- lib/revtreeview.py 2021-01-05 16:26:04 +0000
+++ lib/revtreeview.py 2022-01-08 10:52:55 +0000
@@ -127,7 +127,7 @@
127 # self.throbber.show()127 # self.throbber.show()
128 # self.load_revisions_throbber_shown = True128 # self.load_revisions_throbber_shown = True
129 # Allow for more scrolling to happen.129 # Allow for more scrolling to happen.
130 self.delay(0.5)130 self.delay(500)
131131
132 return False132 return False
133133

Subscribers

People subscribed via source and target branches