Skip to content

Commit

Permalink
Fix crash when clicking outline (#1299)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ByteOfBrie committed Aug 12, 2024
1 parent 44693e0 commit f35534a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions manuskript/ui/views/outlineDelegates.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit f35534a

Please sign in to comment.