notification: Correctly handle `screen` set in the presets.

It was setting directly to `_private`, which both didn't work
and caused a memory leak.

Fix #3428
This commit is contained in:
Emmanuel Lepage Vallee 2021-09-16 16:26:07 -07:00
parent 21a111d154
commit e752943b98
1 changed files with 9 additions and 1 deletions

View File

@ -882,10 +882,18 @@ local function select_legacy_preset(n, args)
)) ))
for k, v in pairs(n.preset) do for k, v in pairs(n.preset) do
-- Don't keep a strong reference to the screen, Lua 5.1 GC wont be
-- smart enough to unwind the mess of circular weak references.
if k ~= "screen" then
n._private[k] = v n._private[k] = v
end end
end end
if n.preset.screen then
n._private.weak_screen[1] = capi.screen[n.preset.screen]
end
end
--- Create a notification. --- Create a notification.
-- --
-- @tparam table args The argument table containing any of the arguments below. -- @tparam table args The argument table containing any of the arguments below.