1
0

Unregister network callbacks from QT gui

Rework the callback system in QT to make this easy, and avoid
leaking window references that prevent the window from being
GC-ed on close
This commit is contained in:
Neil Booth
2015-11-13 22:42:21 +09:00
parent 0d4de870a5
commit ae4cfc9f0b
8 changed files with 60 additions and 39 deletions

View File

@@ -194,14 +194,21 @@ class Network(util.DaemonThread):
if self.plugins:
self.plugins.set_network(self)
def register_callback(self, event, callback):
def register_callback(self, callback, events):
with self.lock:
self.callbacks[event].append(callback)
for event in events:
self.callbacks[event].append(callback)
def unregister_callback(self, callback):
with self.lock:
for callbacks in self.callbacks.values():
if callback in callbacks:
callbacks.remove(callback)
def trigger_callback(self, event, *args):
with self.lock:
callbacks = self.callbacks[event][:]
[callback(*args) for callback in callbacks]
[callback(event, *args) for callback in callbacks]
def read_recent_servers(self):
if not self.config.path: