[PySide] Signals and recursion

Florian Bruhin me at the-compiler.org
Sat Sep 5 18:46:16 CEST 2020


On Tue, Sep 01, 2020 at 11:51:30AM +0300, Safa Alfulaij wrote:
> I have an object with a notifiable property "value".
> I also have 1000+ instances, each has the previous object's property signal
> connected to it's slot.
> In my testing, I exceed the recursion depth at around object 200.
> It seems that each "emit" pauses the execution, goes to the receiver to
> emit, and so on, which creates new stack frames.
> Any way to "solve" this? Thanks!

Your snippet runs fine for me.

However, you might be able to use Qt.QueuedConnection (rather than the
default Qt.DirectConnection) when calling .connect() to work around
this: https://doc.qt.io/qt-5/qt.html#ConnectionType-enum

This will cause Qt to call your slot when back in the main loop, rather
than directly - it will require having a main loop running, though.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/pyside/attachments/20200905/7a2d7103/attachment.sig>

More information about the PySide mailing list