Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix crash when clicking outline #1315

Merged
merged 5 commits into from
Oct 2, 2024

Conversation

ByteOfBrie
Copy link
Contributor

Fixes the crash in #1299, which ended up being very simple.

I wrote a decent bit of explanation in both of the commits, but for the short summary: At least in the more recent versions of PyQt5, subElementRect for qproxystyle (which is used in paint) expects three arguments, instead of having a default value for widget of None.

This shouldn't be a problem even if older versions do have a default value, since it would already be None.

connect_qtconsole's profile option was apparently deprecated in
ipykernel 4.2.2

The commit is here: ipython/ipykernel@ef01782
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.
@ByteOfBrie
Copy link
Contributor Author

I managed to get another crash still based on this, so it's apparently not ready to merge quite yet.

@ByteOfBrie ByteOfBrie marked this pull request as draft August 13, 2024 01:17
A few more places in my previous commit didn't break in my "test"
project (presumably because they weren't being drawn), but after
switching back to a real project, they broke again.

This does more of the same thing (using `None` instead of relying on the
default argument, which is missing)
@ByteOfBrie ByteOfBrie marked this pull request as ready for review August 13, 2024 01:56
This time I actually went through the docs and found all the elements in
`qproxystyle` that didn't have a default value for the widget, which are

```
sizeFromContents
subControlRect
subElementRect
```

and then went through the entire Manuskript project with grep and made
sure I didn't leave any more places that needed this change.

I confirmed that I would also crash in the full screen editor -- I'm not
sure how to get to the collapsibleGroupBox code within Manuskript
itself, but from looking at the code, it's almost definitely the same
issue.
@TheJackiMonster TheJackiMonster added this to the 0.17.0 milestone Aug 13, 2024
It appears to be using a different type base QT object, so it doesn't
cause a crash here. It wouldn't have hurt anything, but still better to
not make a change when it's unnecessary
@ByteOfBrie
Copy link
Contributor Author

This is ready to be merged whenever you want, it's totally done on my end. There aren't any more crashes around this behavior that I'm aware of.

@TheJackiMonster TheJackiMonster merged commit 54d2ca1 into olivierkes:develop Oct 2, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants