From 2b06b55994788cb363e70ffd15c7abd95bdf4af6 Mon Sep 17 00:00:00 2001 From: Yann Leboulanger Date: Sun, 3 Sep 2006 20:21:26 +0000 Subject: [PATCH] close chat window when we remove an account. Fixes #2370 --- src/config.py | 2 +- src/roster_window.py | 19 +++++++++++++++---- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/config.py b/src/config.py index 19c8bddc7..07fa3b14d 100644 --- a/src/config.py +++ b/src/config.py @@ -2275,7 +2275,7 @@ class RemoveAccountWindow: if not res: return # Close all opened windows - gajim.interface.roster.close_all(gajim.interface.instances[self.account]) + gajim.interface.roster.close_all(self.account) gajim.connections[self.account].disconnect(on_purpose = True) del gajim.connections[self.account] gajim.config.del_per('accounts', self.account) diff --git a/src/roster_window.py b/src/roster_window.py index f6cae8044..c1886fabd 100644 --- a/src/roster_window.py +++ b/src/roster_window.py @@ -2613,13 +2613,19 @@ _('If "%s" accepts this request you will know his or her status.') % jid) def on_profile_avatar_menuitem_activate(self, widget, account): gajim.interface.edit_own_details(account) - def close_all(self, dic): + def close_all_from_dict(self, dic): '''close all the windows in the given dictionary''' for w in dic.values(): if type(w) == type({}): - self.close_all(w) + self.close_all_from_dict(w) else: w.window.destroy() + + def close_all(self, account): + '''close all the windows from an account''' + self.close_all_from_dict(gajim.interface.instances[account]) + for ctrl in gajim.interface.msg_win_mgr.get_controls(): + ctrl.parent_win.remove_tab(ctrl) def on_roster_window_delete_event(self, widget, event): '''When we want to close the window''' @@ -2698,7 +2704,7 @@ _('If "%s" accepts this request you will know his or her status.') % jid) gajim.interface.save_config() for account in gajim.connections: gajim.connections[account].quit(True) - self.close_all(gajim.interface.instances) + self.close_all(account) if gajim.interface.systray_enabled: gajim.interface.hide_systray() gtk.main_quit() @@ -3600,7 +3606,12 @@ _('If "%s" accepts this request you will know his or her status.') % jid) if len(self._last_selected_contact): # update unselected rows for (jid, account) in self._last_selected_contact: - self.draw_contact(jid, account) + try: + self.draw_contact(jid, account) + except: + # This can fail when last selected row was on an account we just + # removed. So we don't care if that fail + pass self._last_selected_contact = [] if len(list_of_paths) == 0: return