You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Even if it ought to 'just work out' there should probably be tests added. Though maybe @nicoddemus can elaborate on a scenario where we retain a reference to a signal or slot and they 'go away'. Or perhaps that's the issue and we shouldn't be retaining strong references at all and need to switch to weakrefs.
The text was updated successfully, but these errors were encountered:
Here's a quick example demonstrating how connections are automatically undone if one of the sides is destroyed:
fromPyQt5.QtWidgetsimportQApplication, QPushButtonclassMyObject:
def__init__(self, clicks):
self.clicks=clicksdefon_click(self):
self.clicks.append(1)
defmain():
app=QApplication([])
clicks= []
obj=MyObject(clicks)
button=QPushButton()
button.clicked.connect(obj.on_click)
button.clicked.emit()
assertclicks== [1], obj.clicksdelobj# clicking on the button again won't append to the list because the connection# is undone automaticallybutton.clicked.emit()
assertclicks== [1], obj.clicksmain()
Raised at: innodatalabs/triq#5 (comment)
Even if it ought to 'just work out' there should probably be tests added. Though maybe @nicoddemus can elaborate on a scenario where we retain a reference to a signal or slot and they 'go away'. Or perhaps that's the issue and we shouldn't be retaining strong references at all and need to switch to weakrefs.
The text was updated successfully, but these errors were encountered: