From f7f47320d8d1f8092d09b2395941add3f394b969 Mon Sep 17 00:00:00 2001 From: Mathieu Virbel Date: Mon, 19 Mar 2012 18:23:24 +0100 Subject: [PATCH] widget: throw an exception when the user is trying to add itself to the children. closes #410 --- kivy/uix/widget.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kivy/uix/widget.py b/kivy/uix/widget.py index d21e2dae6..d6d4a4e63 100644 --- a/kivy/uix/widget.py +++ b/kivy/uix/widget.py @@ -222,6 +222,8 @@ class Widget(EventDispatcher): >>> slider = Slider() >>> root.add_widget(slider) ''' + if widget is self: + raise WidgetException('You cannot add yourself in a Widget') if not isinstance(widget, Widget): raise WidgetException( 'add_widget() can be used only with Widget classes.')