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:
parent
089ed0e8dd
commit
d990e7918f
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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")
|
||||||
|
|
|
@ -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
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
|
|
||||||
|
|
|
@ -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()
|
||||||
|
|
|
@ -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()
|
||||||
|
|
|
@ -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()
|
||||||
|
|
|
@ -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()
|
||||||
|
|
Loading…
Reference in New Issue