Use :weak_connect_signal() for connecting to widget::updated

This way "that other widget" doesn't prevent the current widget from being
garbage collected.

Please note that this in all of these cases the widget under consideration does
have a strong reference to the callback function. This means that the callback
cannot be garbage collected until "this widget" itself is collected. Thanks to
this, this change is safe.

Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
Uli Schlachter 2015-06-14 14:27:43 +02:00 committed by Daniel Hahler
parent 089ed0e8dd
commit d990e7918f
9 changed files with 9 additions and 9 deletions

View File

@ -120,7 +120,7 @@ function drawable:set_widget(widget)
self.widget = widget self.widget = widget
if widget then if widget then
widget:connect_signal("widget::updated", self.draw) widget:weak_connect_signal("widget::updated", self.draw)
end end
-- Make sure the widget gets drawn -- Make sure the widget gets drawn

View File

@ -140,7 +140,7 @@ local function widget_changed(layout, old_w, new_w)
end end
if new_w then if new_w then
widget_base.check_widget(new_w) widget_base.check_widget(new_w)
new_w:connect_signal("widget::updated", layout._emit_updated) new_w:weak_connect_signal("widget::updated", layout._emit_updated)
end end
layout._emit_updated() layout._emit_updated()
end end

View File

@ -48,7 +48,7 @@ function constraint:set_widget(widget)
end end
if widget then if widget then
widget_base.check_widget(widget) widget_base.check_widget(widget)
widget:connect_signal("widget::updated", self._emit_updated) widget:weak_connect_signal("widget::updated", self._emit_updated)
end end
self.widget = widget self.widget = widget
self:emit_signal("widget::updated") self:emit_signal("widget::updated")

View File

@ -54,7 +54,7 @@ end
function fixed:add(widget) function fixed:add(widget)
widget_base.check_widget(widget) widget_base.check_widget(widget)
table.insert(self.widgets, widget) table.insert(self.widgets, widget)
widget:connect_signal("widget::updated", self._emit_updated) widget:weak_connect_signal("widget::updated", self._emit_updated)
self._emit_updated() self._emit_updated()
end end

View File

@ -62,7 +62,7 @@ end
function flex:add(widget) function flex:add(widget)
widget_base.check_widget(widget) widget_base.check_widget(widget)
table.insert(self.widgets, widget) table.insert(self.widgets, widget)
widget:connect_signal("widget::updated", self._emit_updated) widget:weak_connect_signal("widget::updated", self._emit_updated)
self._emit_updated() self._emit_updated()
end end

View File

@ -58,7 +58,7 @@ function margin:set_widget(widget)
end end
if widget then if widget then
widget_base.check_widget(widget) widget_base.check_widget(widget)
widget:connect_signal("widget::updated", self._emit_updated) widget:weak_connect_signal("widget::updated", self._emit_updated)
end end
self.widget = widget self.widget = widget
self._emit_updated() self._emit_updated()

View File

@ -60,7 +60,7 @@ function mirror:set_widget(widget)
end end
if widget then if widget then
widget_base.check_widget(widget) widget_base.check_widget(widget)
widget:connect_signal("widget::updated", self._emit_updated) widget:weak_connect_signal("widget::updated", self._emit_updated)
end end
self.widget = widget self.widget = widget
self._emit_updated() self._emit_updated()

View File

@ -61,7 +61,7 @@ function rotate:set_widget(widget)
end end
if widget then if widget then
widget_base.check_widget(widget) widget_base.check_widget(widget)
widget:connect_signal("widget::updated", self._emit_updated) widget:weak_connect_signal("widget::updated", self._emit_updated)
end end
self.widget = widget self.widget = widget
self._emit_updated() self._emit_updated()

View File

@ -62,7 +62,7 @@ function background:set_widget(widget)
end end
if widget then if widget then
base.check_widget(widget) base.check_widget(widget)
widget:connect_signal("widget::updated", self._emit_updated) widget:weak_connect_signal("widget::updated", self._emit_updated)
end end
self.widget = widget self.widget = widget
self._emit_updated() self._emit_updated()