Priority: Not Evaluated
Affects Version/s: 5.15.3, 6.0.3
Fix Version/s: None
In order to be able to pass additional information to the callback, I'm using a lambda function to call the real handler when the signal is triggered.
Doing so works in general, however there is a specific case where this breaks inexplicably: when done in a loop, feeding the lambda a variable that is part of the loop and is out of its scope.
I have built a proof of concept based on the basic tutorial:
This program should write "1" or "2" on its label, depending on which radio button is checked.
If the connecting loop is replaced by the individual connections, commented above it, it works.
Oddly enough if the variable is passed explicitly and re-scoped (see the comment below, the only difference being "num=num" as an additional lambda parameter) it also works.
I have tried reproducing this behaviour in pure python as such:
but this program works as expected, which makes me think that the problem lies somewhere between QT and PySide.
I was able to reproduce this in both PySide2 and PySide6.
I am attaching both my test scripts for convenience.