From c691a0842b28ee03a81f2dbcd8b38477362b5544 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Thu, 3 Jan 2019 01:17:22 -0500 Subject: [PATCH] notification: Prevent Lua errors from causing unlimited timer events. It now runs user defined code, so it can happen. Extra safety is required. --- lib/naughty/notification.lua | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/lib/naughty/notification.lua b/lib/naughty/notification.lua index 138a99150..fd76ff8a9 100644 --- a/lib/naughty/notification.lua +++ b/lib/naughty/notification.lua @@ -244,11 +244,11 @@ end function notification:reset_timeout(new_timeout) if self.timer then self.timer:stop() end - local timeout = new_timeout or self.timeout - self:set_timeout(self, timeout) - self.timeout = timeout + self.timeout = new_timeout or self.timeout - self.timer:start() + if not self.timer.started then + self.timer:start() + end end function notification:set_id(new_id) @@ -264,10 +264,21 @@ function notification:set_timeout(timeout) if self.timer and self._private.timeout == timeout then return end + -- 0 == never if timeout > 0 then local timer_die = timer { timeout = timeout } - timer_die:connect_signal("timeout", function() die(cst.notification_closed_reason.expired) end) - if not self.suspended then --FIXME there's still a dependency loop to fix before it works + + timer_die:connect_signal("timeout", function() + pcall(die, cst.notification_closed_reason.expired) + + -- Prevent infinite timers events on errors. + if timer_die.started then + timer_die:stop() + end + end) + + --FIXME there's still a dependency loop to fix before it works + if not self.suspended then timer_die:start() end