@@ -105,9 +105,10 @@ def display(self, obj, former:Display=None) -> Display:
105105 This is the actual function converting objects into displays.
106106 You don't need to call this method if you just want to add an object to the scene, use add() instead
107107 '''
108+ # prevent reference-loop in groups (groups are taken from the execution env, so the user may not want to display it however we are trying to)
108109 ido = id (obj )
109- assert ido not in self .memo , 'there should not be recursion loops in cascading displays'
110- self .memo .add (ido )
110+ assert ido not in self ._memo , 'there should not be recursion loops in cascading displays'
111+ self ._memo .add (ido )
111112
112113 try :
113114 # no refresh if object has not changed
@@ -136,7 +137,7 @@ def display(self, obj, former:Display=None) -> Display:
136137 raise TypeError ('the display for {} is not a subclass of Display: {}' .format (type (obj ).__name__ , type (disp )))
137138
138139 finally :
139- self .memo .remove (ido )
140+ self ._memo .remove (ido )
140141
141142 # keeping a reference of the source object may increas the RAM used but avoid to refresh displays when updating the scene with the same constant value
142143 if self .options ['track_source' ]:
@@ -217,6 +218,8 @@ def render(self, view):
217218
218219 def selection_add (self , display :Display , sub :int = None ):
219220 ''' select the given display '''
221+ if not hasattr (display , 'selected' ):
222+ raise TypeError ('{} is not selectable' .format (type (display ).__name__ ))
220223 if isinstance (display .selected , set ):
221224 display .selected .add (sub )
222225 display .selected = display .selected
@@ -228,6 +231,8 @@ def selection_add(self, display:Display, sub:int=None):
228231
229232 def selection_remove (self , display :Display , sub :int = None ):
230233 ''' deselect the given display '''
234+ if not hasattr (display , 'selected' ):
235+ raise TypeError ('{} is not selectable' .format (type (display ).__name__ ))
231236 if isinstance (display .selected , set ):
232237 if sub is None :
233238 display .selected .clear ()
@@ -242,6 +247,8 @@ def selection_remove(self, display:Display, sub:int=None):
242247 self .touch ()
243248
244249 def selection_toggle (self , display :Display , sub :int = None ):
250+ if not hasattr (display , 'selected' ):
251+ raise TypeError ('{} is not selectable' .format (type (display ).__name__ ))
245252 if isinstance (display .selected , set ):
246253 selected = sub in display .selected
247254 else :
0 commit comments