Details
Description
If you connect to a slot (a method with decorate Slot) after disconnecting a non-existent connection to the same slot it causes "segmentation fault".
from PySide6.QtCore import QCoreApplication, QObject, QTimer, Signal, Slot class Foo(QObject): foo_signal = Signal() def bar(self): pass @Slot() def baz(self): pass def test_without_slot(self): try: self.foo_signal.disconnect(self.bar) except RuntimeError as e: print(e) self.foo_signal.connect(self.bar) print("test_without_slot: after connect") def test_with_slot(self): try: self.foo_signal.disconnect(self.baz) except RuntimeError as e: print(e) self.foo_signal.connect(self.baz) print("test_with_slot: after connect") if __name__ == "__main__": app = QCoreApplication() foo = Foo() QTimer.singleShot(1000, foo.test_without_slot) QTimer.singleShot(2000, foo.test_with_slot) QTimer.singleShot(5000, app.quit) app.exec()
Failed to disconnect signal foo_signal(). test_without_slot: after connect Failed to disconnect signal foo_signal(). [1] 89466 segmentation fault (core dumped) python main.py
Attachments
For Gerrit Dashboard: PYSIDE-1715 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
382163,2 | PySide6: Fix crash when connecting slot after disconnecting non-existent connection to same slot | dev | pyside/pyside-setup | Status: MERGED | +2 | 0 |
382289,2 | PySide6: Fix crash when connecting slot after disconnecting non-existent connection to same slot | 6.2 | pyside/pyside-setup | Status: MERGED | +2 | 0 |
382290,3 | PySide6: Fix crash when connecting slot after disconnecting non-existent connection to same slot | tqtc/lts-5.15 | pyside/tqtc-pyside-setup | Status: MERGED | +2 | 0 |