don't remove contact instance when we remove last event if a chat is stil opened, but when we close the window. Should fix #4272

This commit is contained in:
Yann Leboulanger 2008-09-16 21:51:48 +00:00
parent 3e2f9fcbec
commit c876e8f65e
2 changed files with 37 additions and 22 deletions

View File

@ -2185,6 +2185,14 @@ class ChatControl(ChatControlBase):
# Clean events # Clean events
gajim.events.remove_events(self.account, self.get_full_jid(), gajim.events.remove_events(self.account, self.get_full_jid(),
types = ['printed_' + self.type_id, self.type_id]) types = ['printed_' + self.type_id, self.type_id])
# Remove contact instance if contact has been removed
key = (self.contact.jid, self.account)
roster = gajim.interface.roster
if key in roster.contacts_to_be_removed.keys():
backend = roster.contacts_to_be_removed[key]['backend']
del roster.contacts_to_be_removed[key]
roster.remove_contact(self.contact.jid, self.account, force=True,
backend=backend)
# remove all register handlers on widgets, created by self.xml # remove all register handlers on widgets, created by self.xml
# to prevent circular references among objects # to prevent circular references among objects
for i in self.handlers.keys(): for i in self.handlers.keys():

View File

@ -732,18 +732,23 @@ class RosterWindow:
''' '''
contact = gajim.contacts.get_contact_with_highest_priority(account, jid) contact = gajim.contacts.get_contact_with_highest_priority(account, jid)
if not contact:
iters = self._get_contact_iter(jid, account, contact, self.model)
if not iters:
return return
if not force and self.contact_has_pending_roster_events(contact, account): if not force and (self.contact_has_pending_roster_events(contact,
# Contact has pending events account) or gajim.interface.msg_win_mgr.get_control(jid, account)):
# Contact has pending events or window
#TODO: or single message windows? Bur they are not listed for the
# moment
key = (jid, account) key = (jid, account)
if not key in self.contacts_to_be_removed: if not key in self.contacts_to_be_removed:
self.contacts_to_be_removed[key] = {'backend': backend} self.contacts_to_be_removed[key] = {'backend': backend}
return False # if more pending event, don't remove from roster
else: if self.contact_has_pending_roster_events(contact, account):
return False
iters = self._get_contact_iter(jid, account, contact, self.model)
if iters:
# no more pending events # no more pending events
# Remove contact from roster directly # Remove contact from roster directly
family = gajim.contacts.get_metacontacts_family(account, jid) family = gajim.contacts.get_metacontacts_family(account, jid)
@ -753,27 +758,29 @@ class RosterWindow:
else: else:
self._remove_entity(contact, account) self._remove_entity(contact, account)
if backend: if backend and (not gajim.interface.msg_win_mgr.get_control(jid, account)\
# Remove contact before redrawing, otherwise the old or force):
# numbers will still be show # If a window is still opened: don't remove contact instance
gajim.contacts.remove_jid(account, jid, remove_meta=True) # Remove contact before redrawing, otherwise the old
if family: # numbers will still be show
# reshow the rest of the family gajim.contacts.remove_jid(account, jid, remove_meta=True)
brothers = self._add_metacontact_family(family, account) if iters and family:
for c, acc in brothers: # reshow the rest of the family
self.draw_contact(c.jid, acc) brothers = self._add_metacontact_family(family, account)
self.draw_mood(c.jid, acc) for c, acc in brothers:
self.draw_activity(c.jid, acc) self.draw_contact(c.jid, acc)
self.draw_tune(c.jid, acc) self.draw_mood(c.jid, acc)
self.draw_avatar(c.jid, acc) self.draw_activity(c.jid, acc)
self.draw_tune(c.jid, acc)
self.draw_avatar(c.jid, acc)
if iters:
# Draw all groups of the contact # Draw all groups of the contact
for group in contact.get_shown_groups(): for group in contact.get_shown_groups():
self.draw_group(group, account) self.draw_group(group, account)
self.draw_account(account) self.draw_account(account)
return True return True
def add_groupchat(self, jid, account, status=''): def add_groupchat(self, jid, account, status=''):
'''Add groupchat to roster and draw it. '''Add groupchat to roster and draw it.