From e752943b985b0bf30942a4c891e73c6eebf1c475 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Thu, 16 Sep 2021 16:26:07 -0700 Subject: [PATCH] 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 --- lib/naughty/notification.lua | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/naughty/notification.lua b/lib/naughty/notification.lua index 860eec08c..5ef46c318 100644 --- a/lib/naughty/notification.lua +++ b/lib/naughty/notification.lua @@ -882,7 +882,15 @@ local function select_legacy_preset(n, args) )) for k, v in pairs(n.preset) do - n._private[k] = v + -- 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 + end + end + + if n.preset.screen then + n._private.weak_screen[1] = capi.screen[n.preset.screen] end end