Fix a bug with the _close_tab shortcut

on_close wasn’t used correctly everywhere.
Also make the "close" commands for each tab specific to themselves,
rather than taking the current tab for closure.
This commit is contained in:
mathieui 2016-07-22 19:56:07 +02:00
parent 89194356ee
commit 8634b5ea66
7 changed files with 13 additions and 8 deletions

View file

@ -1346,9 +1346,9 @@ class Core(object):
tab = self.current_tab()
if isinstance(tab, tabs.RosterInfoTab):
return # The tab 0 should NEVER be closed
tab.on_close()
del tab.key_func # Remove self references
del tab.commands # and make the object collectable
tab.on_close()
nb = tab.nb
if was_current:
if self.previous_tab_nb != nb:

View file

@ -58,7 +58,7 @@ class BookmarksTab(Tab):
self.removed_bookmarks.append(current)
def on_cancel(self):
self.core.close_tab()
self.core.close_tab(self)
return True
def on_save(self):
@ -85,7 +85,7 @@ class BookmarksTab(Tab):
self.core.information('Remote bookmarks not saved.', 'Error')
log.debug('alerte %s', str(stanza_storage(self.bookmarks.bookmarks)))
self.bookmarks.save(self.core.xmpp, callback=send_cb)
self.core.close_tab()
self.core.close_tab(self)
return True
def on_input(self, key, raw=False):

View file

@ -207,7 +207,7 @@ class ConversationTab(OneToOneTab):
@command_args_parser.ignored
def command_unquery(self):
self.core.close_tab()
self.core.close_tab(self)
@command_args_parser.quoted(0, 1)
def command_version(self, args):

View file

@ -111,7 +111,6 @@ class ListTab(Tab):
self.input.do_command("/") # we add the slash
def close(self, arg=None):
self.input.on_delete()
self.core.close_tab(self)
def set_error(self, msg, code, body):

View file

@ -624,7 +624,11 @@ class MucTab(ChatTab):
/close [msg]
"""
self.command_part(msg)
self.core.close_tab()
self.core.close_tab(self)
def on_close(self):
super().on_close()
self.command_part('')
@command_args_parser.quoted(1, 1)
def command_query(self, args):

View file

@ -96,6 +96,7 @@ class PrivateTab(OneToOneTab):
self.core.information('Unable to write in the log file', 'Error')
def on_close(self):
super().on_close()
self.parent_muc.privates.remove(self)
def completion(self):
@ -188,7 +189,7 @@ class PrivateTab(OneToOneTab):
"""
/unquery
"""
self.core.close_tab()
self.core.close_tab(self)
@command_args_parser.quoted(0, 1)
def command_version(self, args):

View file

@ -303,7 +303,7 @@ class XMLTab(Tab):
return self.key_func[key]()
def close(self, arg=None):
self.core.close_tab()
self.core.close_tab(self)
def resize(self):
self.need_resize = False
@ -348,6 +348,7 @@ class XMLTab(Tab):
curses.curs_set(0)
def on_close(self):
super().on_close()
self.command_clear('')
self.core.xml_tab = False