File tree 2 files changed +19
-6
lines changed
2 files changed +19
-6
lines changed Original file line number Diff line number Diff line change @@ -41,23 +41,35 @@ describe("Awesome-slot", function()
41
41
42
42
slot .remove (s )
43
43
44
+ assert .is_false (s .connected ) -- remove should also invoke disconnect_signal
44
45
assert .is_nil (slot .get_slot (s ))
45
46
end )
46
47
47
- it (" should connect slot (from constructor parameters) " , function ()
48
+ it (" should automatically connect slot" , function ()
48
49
local target = new_target ()
49
50
50
51
local s = slot {
51
52
target = target ,
52
53
signal = " signal" ,
53
54
slot = function () end ,
54
- slot_params = { key = " value" },
55
- connect = true ,
56
55
}
57
56
58
57
assert .is_true (s .connected )
59
58
end )
60
59
60
+ it (" should prevent slot connection with parameter" , function ()
61
+ local target = new_target ()
62
+
63
+ local s = slot {
64
+ target = target ,
65
+ signal = " signal" ,
66
+ slot = function () end ,
67
+ connect = false ,
68
+ }
69
+
70
+ assert .is_false (s .connected )
71
+ end )
72
+
61
73
it (" should connect signal" , function ()
62
74
local target = new_target ()
63
75
@@ -66,6 +78,7 @@ describe("Awesome-slot", function()
66
78
signal = " signal" ,
67
79
slot = function () end ,
68
80
slot_params = { key = " value" },
81
+ connect = false ,
69
82
}
70
83
71
84
slot .connect (s )
Original file line number Diff line number Diff line change 110
110
-- @tparam table params.slot_params The parameters to pass to the callback
111
111
-- function. (The signal will invoke the callback function with this table as
112
112
-- parameter)
113
- -- @tparam [opt=false ] boolean params.connect Connect the slot now.
113
+ -- @tparam [opt=true ] boolean params.connect Connect the slot now.
114
114
-- @treturn Slot The created Slot instance.
115
115
-- @constructorfct awesome_slot
116
116
function awesome_slot .create (params )
@@ -127,7 +127,7 @@ function awesome_slot.create(params)
127
127
-- Insert the new slot into the slots list
128
128
awesome_slot ._private .registered_slots [slot .id ] = slot
129
129
130
- if params .connect then
130
+ if params .connect == nil or params . connect then
131
131
awesome_slot .connect (slot )
132
132
end
133
133
@@ -142,7 +142,7 @@ function awesome_slot.remove(slot)
142
142
local s = awesome_slot .get_slot (slot )
143
143
144
144
if s .connected then
145
- awesome_slot .disconnect_slot (s )
145
+ awesome_slot .disconnect (s )
146
146
end
147
147
148
148
awesome_slot ._private .registered_slots [s .id ] = nil
You can’t perform that action at this time.
0 commit comments