Disconnect focus-out callback when xxx2many widget is destroyed

Once destroyed, the linked screen has no view to call set_value on.

issue7259
review36071002
This commit is contained in:
Cédric Krier committed 2018-03-27 10:46:16 +02:00
1 parent 266eb42fcc
commit 5e2829fcd4
3 files changed
+6 -4

No files matched your search

@@ -47,7 +47,7 @@ class Many2Many(Widget):
self.wid_text = PlaceholderEntry()
self.wid_text.set_placeholder_text(_('Search'))
self.wid_text.set_property('width_chars', 13)
self.wid_text.connect('focus-out-event', lambda *a: self._focus_out())
self.wid_text.connect('focus-out-event', self._focus_out)
self.focus_out = True
hbox.pack_start(self.wid_text, expand=True, fill=True)
@@ -139,6 +139,7 @@ class Many2Many(Widget):
return False
def destroy(self):
self.wid_text.disconnect_by_func(self._focus_out)
self.screen.destroy()
def _sig_add(self, *args):
@@ -90,8 +90,7 @@ class One2Many(Widget):
self.wid_text = PlaceholderEntry()
self.wid_text.set_placeholder_text(_('Search'))
self.wid_text.set_property('width_chars', 13)
self.wid_text.connect('focus-out-event',
lambda *a: self._focus_out())
self.wid_text.connect('focus-out-event', self._focus_out)
hbox.pack_start(self.wid_text, expand=True, fill=True)
if int(self.attrs.get('completion', 1)):
@@ -235,6 +234,8 @@ class One2Many(Widget):
return False
def destroy(self):
if self.attrs.get('add_remove'):
self.wid_text.disconnect_by_func(self._focus_out)
self.screen.destroy()
def _on_activate(self):
@@ -86,7 +86,7 @@ class Widget(object):
self.visible = True
widget.show()
def _focus_out(self):
def _focus_out(self, *args):
if not self.field:
return False
if not self.visible: