disconnect only slots that got connected#2923
Conversation
PySide 6.7 will stop raising an exception when attempting to disconnect a slot that wasn't connected in the first place. It will instead print out a warning.
|
I don't understand the condition in the following code: Based on my testing script below, the expression def func_indirect(x):
return x
def func1(x):
# "'x' in locals" is True
return lambda : func_indirect(x) if 'x' in locals() else None
def func2(x):
y = 2 * x
# "'y' in locals" is False
return lambda : func_indirect(x) if 'y' in locals() else None
print(func1(1)()) # 1
print(func2(2)()) # None |
|
I got interested in what was happening with |
|
UPDATE: So there isn't any bug. The issue with my failed attempt is that knowing that a signal has slot(s) connected is not a sufficient condition for ascertaining whether a particular slot is connected. |
12982a2 to
b04085e
Compare
this test will fail on PySide6 6.7
|
Thanks @pijyoi Always nice when we can address an issue before the upstream library makes a change. Appreciate your effort to look ahead and mitigate issues per-emptively. |
Sorry for the late reply @pijyoi ! The reason for this code is that the callback can be invoked during python teardown (in which case some of these locals may already have been deleted). I think this just avoids error messages that would appear on exit, but it's also possible that it prevented segmentation faults at exit, which were common at the time this was written. |
PySide 6.7 will stop raising an exception when attempting to disconnect a slot that wasn't connected in the first place.
It will instead print out a warning.
See:
https://code.qt.io/cgit/pyside/pyside-setup.git/commit/?id=d7aa15abe25bd71ea19180743ce9b41e0b788520
This PR fixes:
GraphicsItem.Remaining code that still cause warnings: