From 8f48c5ede7e1da18f85daae9bda5a4b68272498b Mon Sep 17 00:00:00 2001 From: Florent Le Coz Date: Mon, 7 Mar 2011 21:41:13 +0100 Subject: Inputs are garbage collected, making MucListTab collectable. Memory improvement issues. --- src/windows.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src/windows.py') diff --git a/src/windows.py b/src/windows.py index a949ca99..e6ca9800 100644 --- a/src/windows.py +++ b/src/windows.py @@ -734,6 +734,13 @@ class Input(Win): self.on_input = None # callback called on any key pressed self.color = None # use this color on addstr + def on_delete(self): + """ + Remove all references kept to a tab, so that the tab + can be garbage collected + """ + del self.key_func + def set_color(self, color): self.color = color self.rewrite_text() @@ -1171,6 +1178,22 @@ class CommandInput(Input): self.addstr(0, cursor_pos, '') # WTF, this works but .move() doesn't… self._refresh() + def on_delete(self): + """ + SERIOUSLY BIG WTF. + + I can do + self.key_func.clear() + + but not + del self.key_func + because that would raise an AttributeError exception. WTF. + """ + self.on_abort = None + self.on_success = None + self.on_input = None + self.key_func.clear() + class VerticalSeparator(Win): """ Just a one-column window, with just a line in it, that is -- cgit v1.2.3