bug(a.keygrabber): Stop timer when stopping keygrabber

When stopping a keygrabber with a timeout manually or through the stop
key, the timer would continue and call the stop callback again some time
later.

The error message in `gears.timer:stop` is removed, since there actually
is no harm in just returning immediately. And the timer implementation
itself calls `:stop` in certain places without checking for `.started`,
which lead to a situation where the internal call to `stop` triggered
the error message.

Signed-off-by: Lucas Schwiderski <lucas@lschwiderski.de>
This commit is contained in:
Lucas Schwiderski 2021-05-26 23:17:43 +02:00
parent b65025ef62
commit 1182552783
No known key found for this signature in database
GPG Key ID: AA12679AAA6DF4D8
2 changed files with 11 additions and 1 deletions

View File

@ -474,12 +474,20 @@ function keygrabber:start()
end
--- Stop the keygrabber.
--
-- Also stops any `timeout`.
--
-- @method stop
-- @emits stopped
-- @emits property::current_instance
function keygrabber:stop(_stop_key, _stop_mods) -- (at)function disables ldoc params
keygrab.stop(self.grabber)
local timer = self._private.timer
if timer and timer.started then
timer:stop()
end
if self.stop_callback then
self.stop_callback(
self.current_instance, _stop_key, _stop_mods, self.sequence

View File

@ -99,11 +99,13 @@ function timer:start()
end
--- Stop the timer.
--
-- Does nothing if the timer isn't running.
--
-- @method stop
-- @emits stop
function timer:stop()
if self.data.source_id == nil then
gdebug.print_error(traceback("timer not started"))
return
end
glib.source_remove(self.data.source_id)