diff --git a/lib/wibox/widget/template.lua b/lib/wibox/widget/template.lua index af86e7e11..18600a61f 100644 --- a/lib/wibox/widget/template.lua +++ b/lib/wibox/widget/template.lua @@ -16,10 +16,6 @@ local wbase = require("wibox.widget.base") local gtable = require("gears.table") local gtimer = require("gears.timer") -local default_update_callback = function() - return nil -end - local default_template_widget = wbase.empty_widget() local template = { @@ -28,7 +24,9 @@ local template = { } function template:_do_update_now(args) - self:update_callback(args) + if type(self.update_callback) == 'function' then + self:update_callback(args) + end template.queued_updates[self] = false end @@ -73,7 +71,7 @@ function template.new(args) local widget = wbase.make_widget_from_value(widget_template) - widget.update_callback = args.update_callback or default_update_callback + widget.update_callback = args.update_callback widget.update_args = args.update_args or {} gtable.crush(widget, template, true) diff --git a/spec/wibox/widget/template_spec.lua b/spec/wibox/widget/template_spec.lua index 7fad45622..e73ef568c 100644 --- a/spec/wibox/widget/template_spec.lua +++ b/spec/wibox/widget/template_spec.lua @@ -32,7 +32,7 @@ describe("wibox.widget.template", function() it("batch calls", function() local spied_update_callback = spy.new(function() end) - widget.update_callback = spied_update_callback + widget.update_callback = function(...) spied_update_callback(...) end -- Multiple calls to update widget:update() @@ -54,7 +54,7 @@ describe("wibox.widget.template", function() local update_args = { foo = "bar" } widget.update_args = args_structure - widget.update_callback = spied_update_callback + widget.update_callback = function(...) spied_update_callback(...) end widget:update(update_args)