From ac99467965ba04282b6dbc63c5c04ab91ba1b007 Mon Sep 17 00:00:00 2001 From: Florent Le Coz Date: Sun, 13 Feb 2011 22:28:35 +0100 Subject: Make the tab collectable by remove self references when closing them. --- src/core.py | 2 ++ src/room.py | 1 - src/tabs.py | 3 +++ src/text_buffer.py | 7 ++++++- src/windows.py | 4 ++++ 5 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/core.py b/src/core.py index 41ec12f2..98d2a7fa 100644 --- a/src/core.py +++ b/src/core.py @@ -1303,6 +1303,8 @@ class Core(object): tab.on_close() self.tabs.remove(tab) self.rotate_rooms_left() + del tab.key_func # Remove self references + del tab.commands # and make the object collectable del tab def move_separator(self): diff --git a/src/room.py b/src/room.py index 9bb9f721..29986142 100644 --- a/src/room.py +++ b/src/room.py @@ -123,4 +123,3 @@ class Room(TextBuffer): nb = window.build_new_message(message) if window.pos != 0: window.scroll_up(nb) - diff --git a/src/tabs.py b/src/tabs.py index ecb53ab9..3c91fc14 100644 --- a/src/tabs.py +++ b/src/tabs.py @@ -210,6 +210,9 @@ class Tab(object): """ pass + def __del__(self): + log.debug('Closing tab %s' % self.__class__.__name__) + class ChatTab(Tab): """ A tab containing a chat of any type. diff --git a/src/text_buffer.py b/src/text_buffer.py index 828b344c..9285a433 100644 --- a/src/text_buffer.py +++ b/src/text_buffer.py @@ -36,7 +36,7 @@ class TextBuffer(object): self.messages = [] # Message objects self.windows = [] # we keep track of one or more windows # so we can pass the new messages to them, as they are added, so - # they (the windows) can built the lines from the new message + # they (the windows) can build the lines from the new message def add_window(self, win): self.windows.append(win) @@ -55,3 +55,8 @@ class TextBuffer(object): if window.pos != 0: window.scroll_up(nb) + def del_window(self, win): + self.windows.remove(win) + + def __del__(self): + log.debug('** Deleting %s messages from textbuffer' % (len(self.messages))) diff --git a/src/windows.py b/src/windows.py index dfb75006..c46b60e3 100644 --- a/src/windows.py +++ b/src/windows.py @@ -637,6 +637,10 @@ class TextWin(Win): for message in room.messages: self.build_new_message(message) + def __del__(self): + log.debug('** TextWin: deleting %s built lines' % (len(self.built_lines))) + del self.built_lines + class HelpText(Win): """ A Window just displaying a read-only message. -- cgit v1.2.3