Skip to content

[patched-9] Backport recent changes from MeVisLab/pythonqt #87

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

Merged
merged 157 commits into from
Jan 28, 2024

Conversation

jcfr
Copy link
Member

@jcfr jcfr commented Dec 14, 2023

Meticulous backport of all recent changes introduced in https://github.com/MeVisLab/pythonqt/

Commit impacting only the PythonQt library are prefix with [Backport] the one impacting only the generator are prefixed with [Backport generator].

Changes related to the GitHub workflow continuous integration have not been backported.

usiems and others added 30 commits December 10, 2023 16:56
…nd QFontMetrics

These are needed when these types are returned by value (as for example from QWidget)

(cherry picked from commit MeVisLab/pythonqt@04e2c1b)
This prevents `file not found with <angled> include; use "quotes" instead` errors.

(cherry picked from commit MeVisLab/pythonqt@b58b776)
With Python 3.8, python3-config --libs doesn't contain the python link target.
To avoid link issues, we first test if the python config utility accepts the
'--embed' parameter and use the output when possible.

Fixes: issue#6

(cherry picked from commit MeVisLab/pythonqt@8ea8264)
The last element was not deleted even when it is the single one in the list.

(cherry picked from commit MeVisLab/pythonqt@0158ffb)
The problem was that the "with" statement doesn't use the conventional __getattr__ access, but directly accesses the tp_dict of the type, which usually is empty in PythonQt, so we had to put the __enter__ and __exit__ methods there, too.
And for binding the methods to the instance, tp_descr_get was used in this case, so we had to implement that for slots, too.

Discussed with and reviewed by Florian Link

(cherry picked from commit MeVisLab/pythonqt@d13b66c)
…r QMutexLocker, QReadLocker, and QWriteLocker

(cherry picked from commit MeVisLab/pythonqt@0e6a9b1)
(adapted from commit MeVisLab/pythonqt@525ea41)

Since the changes to "src/PythonQt.cpp" are reverted through
e01fe14 (Revert "More potential leak fixes and build fix"),
this commit only backports the changes to "build/python.prf".
This could happen if the signal target was removed in the callback, which could lead to an invalid signalId being returned. I guess this could lead to the signal receiver destroyed out of turn.

(cherry picked from commit MeVisLab/pythonqt@b5a88e1)
…rk for Qt 5

QUrl::FormattingOptions has the peculiar situation that it actually consists of values from QUrl::UrlFormattingOption and QUrl::ComponentFormattingOption.
It seems the moc doesn't support this situation, so at least support the UrlFormattingOption values.
(I left the old entry in to support Qt 4, but I don't know if PythonQt even still works with Qt 5)

(cherry picked from commit MeVisLab/pythonqt@58ccd53)
This fixes a warning in Visual Studio 2019 ≥16.6 in C++14/17 mode (and error in C++ 20 mode)

(cherry picked from commit MeVisLab/pythonqt@fa274d2)
- trying with -std=c++98 failed with a lot of various errors

(cherry picked from commit MeVisLab/pythonqt@2a24a2b)
(cherry-picked and adapted from MeVisLab/pythonqt@c00ebf4)

It replaces occurrences of NULL with nullptr, switches from usage of "0"
to nullptr where a pointer is expected and fixes indentation of comments
in type structure (e.g PythonQtSlotFunction_Type)

It replaces comment "/* tp_print */" with "/* tp_vectorcall_offset */".
Starting with Python 3.0, the slot was unused. Then it was renamed in
Python 3.8 to support the new "vectorcall" protocol.
See https://docs.python.org/3/c-api/typeobj.html#c.PyTypeObject.tp_vectorcall_offset
and https://peps.python.org/pep-0590/#changes-to-the-pytypeobject-struct

It resolves conflicts in PythonQt.cpp maintaining changes introduced in this fork.
- uses global includes where needed

(cherry picked from commit MeVisLab/pythonqt@2a761ea)
- remove unused variable

(cherry picked from commit MeVisLab/pythonqt@17cf766)
- on async signal handlers
(originally provided by @usiems)

(cherry picked from commit MeVisLab/pythonqt@575c51f)
…re safe

- patch as proposed by Florian Link

(cherry picked from commit MeVisLab/pythonqt@92af018)
since that better matches the actual behavior

(cherry picked from commit MeVisLab/pythonqt@61c6557)
Since the enum values can be duplicates (they only need to be unique in the scope of the enum class) I opted to prefix them with the enum class name (and an underscore) in the generated wrapper.
It would have been nice to use a Python Enum class instead, but after a quick look this seemed to be quite a lot of work.

(cherry picked from commit MeVisLab/pythonqt@c707bcc)
The resulting enumValueRedirection was not used in the PythonQt generator.
Perhaps it was a remnant of the original Java wrapper generator.

(cherry picked from commit MeVisLab/pythonqt@4c61ee7)
… private

obviously copying the object is explicitly prohibited

(cherry picked from commit MeVisLab/pythonqt@f6f00fe)
(in this case assignment operators of QEvent-derived classes in Qt6)

(cherry picked from commit MeVisLab/pythonqt@65f9210)
… classes,

rather re-create enum class as a enum class, and later handle enum
classes in PythonQt itself.

(cherry picked from commit MeVisLab/pythonqt@19cc4c2)
@jcfr
Copy link
Member Author

jcfr commented Dec 14, 2023

Related to:

@jamesobutler this is complementary to the integration of the generated 5.15 wrappers.

@jamesobutler
Copy link

jamesobutler commented Dec 14, 2023

Is there a reason to backport all these commits onto the existing patched-9 branch rather than creating a new branch with a new base and putting the CommonTK customizations on top (like https://github.com/jamesobutler/PythonQt/tree/patched-11)?

@jcfr
Copy link
Member Author

jcfr commented Dec 15, 2023

Few days ago, I was initially backporting selected commits and ended up integrating them all.

It was also the opportunity to review all the ones updating PythonQt library and identify the one I still need to upstream.

@jamesobutler
Copy link

I can try this branch in the context of 3D Slicer. Have you done this already?

One change I needed to do when I initially brought patched-9 customizations on top of latest MeVisLab/PythonQt head, I needed jamesobutler@baca87f to make sure there wasn’t a crash on exit.

Copy link

@jamesobutler jamesobutler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jcfr I have tested this branch in the context of 3D Slicer and I am facing the same crash on exit that I was observing in my work. With jamesobutler@baca87f added onto this branch, 3D Slicer no longer crashes on exit.

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

Successfully merging this pull request may close these issues.