diff frontends/src/quick_frontend/quick_widgets.py @ 1410:e2e75c3c7c7b

quick_frontend, primitivus: fixes a couple of issues: - chat: notification was raising an error when you just entered the room and self.nick is None - quick_widget: deleting a widget was modifying a dict while looping on it + unselect widget when it's being deleted
author souliane <souliane@mailoo.org>
date Thu, 16 Apr 2015 17:17:28 +0200
parents 069ad98b360d
children d17772b0fe22
line wrap: on
line diff
--- a/frontends/src/quick_frontend/quick_widgets.py	Thu Apr 16 14:57:57 2015 +0200
+++ b/frontends/src/quick_frontend/quick_widgets.py	Thu Apr 16 17:17:28 2015 +0200
@@ -232,9 +232,12 @@
         widget_to_delete.onDelete()
 
         for widget_map in self._widgets.itervalues():
+            to_delete = set()
             for hash_, widget in widget_map.iteritems():
                 if widget_to_delete is widget:
-                    del widget_map[hash_]
+                    to_delete.add(hash_)
+            for hash_ in to_delete:
+                del widget_map[hash_]
 
 
 class QuickWidget(object):
@@ -308,3 +311,6 @@
     def onDelete(self):
         """Called when a widget is deleted"""
         log.debug(u"deleting widget {}".format(self)) # Must be implemented by frontends
+        if self.host.selected_widget == self:
+            self.host.selected_widget = None
+