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

ENH: checks to prevent infinite recursion #72

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

fbordignon
Copy link

I was discussing this issue on a fork, please check: commontk/PythonQt#81

Basically I've integrated pyside2 with PythonQt by preventing a stack overflow that was happening because of an infinite recursion.
See results on: https://discourse.slicer.org/t/pythonqt-properties-shadowing-methods/16992

@florianlink
Copy link
Collaborator

I wonder why that class has itself as its parent, shouldn’t that be fixed? PythonQt traverses the Qt metaobject parent hierarchy and it should not be possible to have a class that derived from itself. I suggest to find the reason for the problem and not fixing it at this place. Maybe you can fix it also by checking the parent info when it gets created, and not add itself as parent class in the first place.

@fbordignon
Copy link
Author

I see, I am wrapping a PythonQt qt layout with shiboken2 and adding a pyside2 widget to it:

lw = PlotLayout.register().layout()
PlotLayout.show()

# wrap pythonQt instance with shiboken2 (pyside2)
pysidelayout = shiboken2.wrapInstance(hash(lw), QVBoxLayout)

pg.mkQApp()

# start of pyqtgraph plotting example https://github.com/pyqtgraph/pyqtgraph/blob/master/examples/Plotting.py
win = pg.GraphicsLayoutWidget(show=True, title="Basic plotting examples")
pysidelayout.addWidget(win)

So something assigns the parent as itself when I add the widget to the PythonQt layout. I don't know how that happens and don't have much time to look into it, so I am sorry but it is too much of a task for me right now. If you have any idea on how to find when this is happening, please let me know. Thanks!

@jbowler
Copy link
Contributor

jbowler commented Oct 14, 2023

This seems to be an assert but because the condition (class with itself as an ancestor) may perhaps be produced by code outside PythonQt a qFatal is probably a better bet; it does the same as an assert but with a potentially more helpful error message:

if (<class has itself as a parent>) qFatal("'%s' is malformed", <name of class>);

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.

3 participants