-
Notifications
You must be signed in to change notification settings - Fork 450
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix memory leak in Downloads page #5949
Conversation
retest this please |
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
@ichorid congrats! 🎊 But I have a question. Are you sure about " don't expect it to be GCed in PyQT until you disconnect the signal manually"? Because:
BTW yes, we always should help GC: spesmilo/electrum#4905 |
I learned the hard way never to trust PyQT promises... 😿 |
@ichorid @qstokkink what do you think, do we have to use something like: class QAutoDisconnectableObject(QObject):
def __init__(self):
super().__init__()
self.connected_signals = set()
connect(self.destroyed, self.on_destroy)
def connect(self, signal, callback):
connect(signal, callback)
self.connected_signals.add(signal)
def on_destroy(self, *args):
for signal in self.connected_signals:
signal.disconnect()
class Table(QAutoDisconnectableObject):
def __init__(self):
super().__init__()
self.connect(self.button.clicked, self.on_button_clicked)
self.connect(self.button1.clicked, self.on_button1_clicked) |
@drew2a It seems useful to have a construction like that: I don't see any downsides to your suggestion. |
Fixes #5934
The moral of the story: if you connect a QT signal to a QT object, don't expect it to be GCed in PyQT until you disconnect the signal manually (or better yet, just reuse the object).