Mercurial > libervia-desktop-kivy
comparison cagou/core/menu.py @ 430:edb240ff7936
core (menu): avoid crash when removing SideMenu from parent if it has already been removed
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 01 Mar 2020 22:11:25 +0100 |
parents | cebf657d78ef |
children | 8607c218807d |
comparison
equal
deleted
inserted
replaced
429:cebf657d78ef | 430:edb240ff7936 |
---|---|
126 G.host.app.root.add_widget(self) | 126 G.host.app.root.add_widget(self) |
127 kw = {'d': 0.3, 't': 'out_back'} | 127 kw = {'d': 0.3, 't': 'out_back'} |
128 self._set_anim_kw(kw, self.size_hint_open, self.size_open) | 128 self._set_anim_kw(kw, self.size_hint_open, self.size_open) |
129 Animation(**kw).start(self) | 129 Animation(**kw).start(self) |
130 | 130 |
131 def _removeFromParent(self, anim, menu): | |
132 # self.parent can already be None if the widget has been removed by a callback | |
133 # before the animation started. | |
134 if self.parent is not None: | |
135 self.parent.remove_widget(self) | |
136 | |
131 def hide(self): | 137 def hide(self): |
132 Window.unbind(on_keyboard=self.key_input) | 138 Window.unbind(on_keyboard=self.key_input) |
133 kw = {'d': 0.2} | 139 kw = {'d': 0.2} |
134 self._set_anim_kw(kw, self.size_hint_close, self.size_close) | 140 self._set_anim_kw(kw, self.size_hint_close, self.size_close) |
135 anim = Animation(**kw) | 141 anim = Animation(**kw) |
136 anim.bind(on_complete=lambda anim, menu: self.parent.remove_widget(self)) | 142 anim.bind(on_complete=self._removeFromParent) |
137 anim.start(self) | 143 anim.start(self) |
138 if self.callback_on_close: | 144 if self.callback_on_close: |
139 self.do_callback() | 145 self.do_callback() |
140 | 146 |
141 def on_touch_down(self, touch): | 147 def on_touch_down(self, touch): |