Make the tab collectable by remove self references when closing

them.
This commit is contained in:
Florent Le Coz 2011-02-13 22:28:35 +01:00
parent 6ed087a65c
commit ac99467965
5 changed files with 15 additions and 2 deletions

View file

@ -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):

View file

@ -123,4 +123,3 @@ class Room(TextBuffer):
nb = window.build_new_message(message)
if window.pos != 0:
window.scroll_up(nb)

View file

@ -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.

View file

@ -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)))

View file

@ -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.