The requirement to call add_signal() was added to catch typos. However, this
requirement became increasingly annoying with property::<name> signals and e.g.
gears.object allowing arbitrary properties to be changed.
All of this ended up in a single commit because tests/examples fails if I first
let add_signal() emit a deprecation warning.
Signed-off-by: Uli Schlachter <psychon@znc.in>
This adds a cyclic dependency between the function used for the weak signal and
an object with a __gc metamethod. The problem occurs since the GC will first
finalize the object (call its __gc metamethod) and only in the next generation
will it actually collect the garbage and remove the functions from weak-tables
using it as a key.
And yes this needs special code for Lua 5.1 because there __gc doesn't work on
tables. :-(
Signed-off-by: Uli Schlachter <psychon@znc.in>
Since weak signals specifically exist to do magic with the garbage collector, do
a couple of garbage collection cycles and verify that this does not disconnect
the callback function prematurely (the function is kept alive since it is a
local variable).
(I actually did a mistake that makes this enhanced test fail and fixed it before
committing)
Signed-off-by: Uli Schlachter <psychon@znc.in>
Connecting to a signal weakly has the same effect as connecting to it strongly,
but it allows the garbage collector to disconnect the signal in case nothing
else references this function.
Signed-off-by: Uli Schlachter <psychon@znc.in>
This uses busted (http://olivinelabs.com/busted/) to implement unit testing.
This is wired up to "make check" and/or "make test".
This commit also adds tests for the more complicated parts of the gears and
wibox.layout libraries.
Signed-off-by: Uli Schlachter <psychon@znc.in>