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

Improve PySide6 Support: swapBehavior for DoubleBuffer, BUTTONMAP as pyqt6, xfail test_context #2411

Merged
merged 4 commits into from Oct 25, 2022

Conversation

psobolewskiPhD
Copy link
Contributor

@psobolewskiPhD psobolewskiPhD commented Oct 22, 2022

Fixes #2407 by using SwapBehavior to set DoubleBuffer
PYSIDE6_API is included in the existing PYQT6_API logic:

if QT5_NEW_API or PYSIDE6_API:
# Qt5 >= 5.4.0 - below options automatically enabled if nonzero.
glformat.setSwapBehavior(glformat.DoubleBuffer if c['double_buffer']
else glformat.SingleBuffer)
elif PYQT6_API:
glformat.setSwapBehavior(glformat.SwapBehavior.DoubleBuffer if c['double_buffer']
else glformat.SwapBehavior.SingleBuffer)

This should work for PySide6 going back to at least 6.2 (LTS)
I found the Qt 6.2 (LTS) docs. The swap behavior was already present.
https://doc.qt.io/qt-6.2/qsurfaceformat.html#SwapBehavior-enum
https://doc.qt.io/qtforpython-6.2/PySide6/QtGui/QSurfaceFormat.html#PySide6.QtGui.PySide6.QtGui.QSurfaceFormat.SwapBehavior

Edit: Also uses the same BUTTONMAP as PyQT6
Plus, xfails the shared context tests: test_context.py
Fixes #2410

@psobolewskiPhD psobolewskiPhD changed the title use same swapbehavior as pyqt6 PySide6: use same SwapBehavior for DoubleBuffer as pyqt6 Oct 22, 2022
@djhoese
Copy link
Member

djhoese commented Oct 22, 2022

So this drops support for older PySide versions (6.1 and 6.2 most likely), this is OK with me. With this single change to the if statement, do your tests from the related issue work now @psobolewskiPhD?

@psobolewskiPhD
Copy link
Contributor Author

So this drops support for older PySide versions (6.1 and 6.2 most likely), this is OK with me. With this single change to the if statement, do your tests from the related issue work now @psobolewskiPhD?

pyside6 6.2 is still fine. the only question is 6.0 and 6.1. I can't install those or find any docs on them.
Alas, it turns out this solves the DoubleBuffer issue, but unmasks a new issue. When running turntable example and trying to interact with the object:

Traceback (most recent call last):
  File "/Users/piotrsobolewski/Dev/vispy/vispy/app/backends/_qt.py", line 515, in mouseReleaseEvent
    button=BUTTONMAP[ev.button()],
KeyError: <MouseButton.LeftButton: 1>
Traceback (most recent call last):
  File "/Users/piotrsobolewski/Dev/vispy/vispy/app/backends/_qt.py", line 515, in mouseReleaseEvent
    button=BUTTONMAP[ev.button()],
KeyError: <MouseButton.LeftButton: 1>

@djhoese
Copy link
Member

djhoese commented Oct 23, 2022

That's probably an update needed here:

if PYQT6_API:

@psobolewskiPhD psobolewskiPhD changed the title PySide6: use same SwapBehavior for DoubleBuffer as pyqt6 Improve PySide6 Support: swapBehavior for DoubleBuffer, BUTTONMAP as pyqt6, skip test_context Oct 23, 2022
@psobolewskiPhD
Copy link
Contributor Author

That's probably an update needed here:

if PYQT6_API:

Thanks for the tip!
Fixed.

I went through everywhere there is PYQT6_API and checked the PySide6 docs. I think everything should be correct now. And I get no errors.

I also added pyside6 to the xfails for shared context, so now the app tests can run without set fault on pyside6 (note that run individually, test_context.py does pass on pyside6 if se_shared_contexts() is set to TRUE, but run as all app tests still segfaults.
This adresses #2410

@psobolewskiPhD psobolewskiPhD changed the title Improve PySide6 Support: swapBehavior for DoubleBuffer, BUTTONMAP as pyqt6, skip test_context Improve PySide6 Support: swapBehavior for DoubleBuffer, BUTTONMAP as pyqt6, xfail test_context Oct 23, 2022
@djhoese djhoese merged commit 69bfc92 into vispy:main Oct 25, 2022
@djhoese
Copy link
Member

djhoese commented Oct 25, 2022

Thanks @psobolewskiPhD!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

test_context test fails with pyside6 error with pyside6 6.4.0 backend on macOS arm64
2 participants