[Sugar-devel] [PATCH sugar] SpreadLayout: do not remove items from the grid if there is none yet, SL #3814

Simon Schampijer simon at schampijer.de
Sun Aug 19 08:55:46 EDT 2012


A grid is added to the ViewContainer when the children
are allocated, we can not do it earlier because we need to
pass the allocation details. The allocation happens when
the children needs to be shown. Therefore if the container
and it's children have not been shown yet, removing the
child from the grid would fail.

This patch does check if a grid exists already before trying
to remove items from it.

Signed-off-by: Simon Schampijer <simon at laptop.org>
---
 src/jarabe/desktop/favoriteslayout.py | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/jarabe/desktop/favoriteslayout.py b/src/jarabe/desktop/favoriteslayout.py
index 0f63f95..e0ee80e 100644
--- a/src/jarabe/desktop/favoriteslayout.py
+++ b/src/jarabe/desktop/favoriteslayout.py
@@ -150,6 +150,11 @@ class SpreadLayout(ViewLayout):
         ViewLayout.__init__(self)
 
     def remove(self, child):
+        if self._grid is None:
+            # the Grid is created during allocation time, so it might not
+            # exist yet when this method is called, SL #3814
+            return
+
         if self._grid.is_in_grid(child):
             self._grid.remove(child)
 
-- 
1.7.11.4



More information about the Sugar-devel mailing list