From f35534a261007dd0ab8867c89e7605dbbe6e0174 Mon Sep 17 00:00:00 2001 From: Brie Date: Mon, 12 Aug 2024 17:47:47 -0400 Subject: [PATCH] Fix crash when clicking outline (#1299) On PyQt5 5.15.11 (the current latest), subElementRect (from qproxystyle) expects three arguments, not two. This isn't consistent with the other subElementRect functions, so I strongly suspect that the problem is somewhere upstream. I see this behavior in the docs and in the package itself, so I don't see a very good way around it. The bindings for subElementRect aren't consistent: ``` bindings/QtWidgets/qcommonstyle.sip 39: virtual QRect subElementRect(QStyle::SubElement r, const QStyleOption *opt, const QWidget *widget = 0) const; bindings/QtWidgets/qproxystyle.sip 41: virtual QRect subElementRect(QStyle::SubElement element, const QStyleOption *option, const QWidget *widget) const; bindings/QtWidgets/qstyle.sip 270: virtual QRect subElementRect(QStyle::SubElement subElement, const QStyleOption *option, const QWidget *widget = 0) const = 0; ``` (`widget` in `qproxystyle` should have a default value of `0`/`nullptr`, but it doesn't) This also shows up in the docs. These have a default: https://www.riverbankcomputing.com/static/Docs/PyQt5/api/qtwidgets/qcommonstyle.html##subElementRect https://www.riverbankcomputing.com/static/Docs/PyQt5/api/qtwidgets/qstyle.html##subElementRect but the one we're using here doesn't: https://www.riverbankcomputing.com/static/Docs/PyQt5/api/qtwidgets/qproxystyle.html##subElementRect Even if other versions have a default value, it should work fine as a positional argument, and `None` would be the default value anyway. --- manuskript/ui/views/outlineDelegates.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/manuskript/ui/views/outlineDelegates.py b/manuskript/ui/views/outlineDelegates.py index 1a9cfa4a..8a970675 100644 --- a/manuskript/ui/views/outlineDelegates.py +++ b/manuskript/ui/views/outlineDelegates.py @@ -29,8 +29,8 @@ def paint(self, painter, option, index): opt = QStyleOptionViewItem(option) self.initStyleOption(opt, index) - iconRect = style.subElementRect(style.SE_ItemViewItemDecoration, opt) - textRect = style.subElementRect(style.SE_ItemViewItemText, opt) + iconRect = style.subElementRect(style.SE_ItemViewItemDecoration, opt, None) + textRect = style.subElementRect(style.SE_ItemViewItemText, opt, None) # Background style.drawPrimitive(style.PE_PanelItemViewItem, opt, painter)