diff --git a/frontends/src/quick_frontend/quick_app.py b/frontends/src/quick_frontend/quick_app.py index 930ec810..8a16864b 100644 --- a/frontends/src/quick_frontend/quick_app.py +++ b/frontends/src/quick_frontend/quick_app.py @@ -215,6 +215,7 @@ class QuickApp(object): self.menus = quick_menus.QuickMenusManager(self) ProfileManager.host = self self.profiles = ProfilesManager() + self._plugs_in_progress = set() # profiles currently being plugged, used to (un)lock contact list updates self.ready_profiles = set() # profiles which are connected and ready self.signals_cache = {} # used to keep signal received between start of plug_profile and when the profile is actualy ready self.contact_lists = quick_contact_list.QuickContactListHandler(self) @@ -401,6 +402,7 @@ class QuickApp(object): @param profile(unicode): %(doc_profile)s """ + self._plugs_in_progress.remove(profile) self.ready_profiles.add(profile) # profile is ready, we can call send signals that where is cache @@ -410,6 +412,8 @@ class QuickApp(object): handler(*args, **kwargs) self.callListeners('profilePlugged', profile=profile) + if not self._plugs_in_progress: + self.contact_lists.lockUpdate(False) def asyncConnect(self, profile, callback=None, errback=None): if not callback: @@ -428,6 +432,8 @@ class QuickApp(object): @param profiles: list of valid profile names """ + self.contact_lists.lockUpdate() + self._plugs_in_progress.update(profiles) self.plugging_profiles() for profile in profiles: self.profiles.plug(profile) diff --git a/frontends/src/quick_frontend/quick_contact_list.py b/frontends/src/quick_frontend/quick_contact_list.py index f841c5fb..9fd16866 100644 --- a/frontends/src/quick_frontend/quick_contact_list.py +++ b/frontends/src/quick_frontend/quick_contact_list.py @@ -645,6 +645,7 @@ class QuickContactListHandler(object): handler = self self._clist = {} # key: profile, value: ProfileContactList self._widgets = set() + self._update_locked = False # se to True to ignore updates def __getitem__(self, profile): """Return ProfileContactList instance for the requested profile""" @@ -857,9 +858,25 @@ class QuickContactListHandler(object): for contact_list in self._clist.itervalues(): contact_list.select(entity) + def lockUpdate(self, locked=True, do_update=True): + """Forbid contact list updates + + Used mainly while profiles are plugged, as many updates can occurs, causing + an impact on performances + @param locked(bool): updates are forbidden if True + @param do_update(bool): if True, a full update is done after unlocking + if set to False, widget state can be inconsistent, be sure to know + what youa re doing! + """ + log.debug(u"Contact lists updates are now {}".format(u"LOCKED" if locked else u"UNLOCKED")) + self._update_locked = locked + if not locked and do_update: + self.update() + def update(self, entities=None, type_=None, profile=None): - for widget in self._widgets: - widget.update(entities, type_, profile) + if not self._update_locked: + for widget in self._widgets: + widget.update(entities, type_, profile) class QuickContactList(QuickWidget):