diff --git a/lib/gears/object.lua b/lib/gears/object.lua index ecae2045c..45620cd8e 100644 --- a/lib/gears/object.lua +++ b/lib/gears/object.lua @@ -62,6 +62,8 @@ end --- Check if the callback is connected to the signal. -- +-- This function check both kind of signal connection (strong and weak). +-- -- @tparam string name The name of the signal. -- @tparam function func The callback to check if connected. -- @treturn boolean Whether the signal is connected. @@ -72,7 +74,7 @@ function object:is_signal_connected(name, func) "callback must be a function, got: " .. type(func) ) local sig = find_signal(self, name) - return not not (sig and sig.strong[func]) + return not not (sig and (sig.strong[func] or sig.weak[func])) end -- Register a global signal receiver. @@ -129,21 +131,6 @@ function object:weak_connect_signal(name, func) sig.weak[func] = make_the_gc_obey(func) end ---- Check if the callback is weakly connected to the signal. --- --- @tparam string name The name of the signal. --- @tparam function func The callback to check if connected. --- @treturn boolean Whether the signal is connected. --- @method is_weak_signal_connected -function object:is_weak_signal_connected(name, func) - assert( - type(func) == "function", - "callback must be a function, got: " .. type(func) - ) - local sig = find_signal(self, name) - return not not (sig and sig.weak[func]) -end - --- Disonnect from a signal. -- @tparam string name The name of the signal. -- @tparam function func The callback that should be disconnected. diff --git a/spec/gears/object_spec.lua b/spec/gears/object_spec.lua index 7ac29068d..fa8250029 100644 --- a/spec/gears/object_spec.lua +++ b/spec/gears/object_spec.lua @@ -195,9 +195,9 @@ describe("gears.object", function() it("is_weak_signal_connected", function() local cb = function()end - assert.is_false(obj:is_weak_signal_connected("signal", cb)) + assert.is_false(obj:is_signal_connected("signal", cb)) obj:weak_connect_signal("signal", cb) - assert.is_true(obj:is_weak_signal_connected("signal", cb)) + assert.is_true(obj:is_signal_connected("signal", cb)) end) end)