mirror of
https://github.com/kikito/beholder.lua.git
synced 2024-12-16 00:34:21 +00:00
fixed an edge case that I can not reproduce with tests
This commit is contained in:
parent
624d4ce48e
commit
37eacc3a41
18
beholder.lua
18
beholder.lua
@ -11,6 +11,14 @@ local function copy(t)
|
|||||||
return c
|
return c
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function hash2array(t)
|
||||||
|
local arr, i = {}, 0
|
||||||
|
for _,v in pairs(t) do
|
||||||
|
i = i+1
|
||||||
|
arr[i] = v
|
||||||
|
end
|
||||||
|
return arr, i
|
||||||
|
end
|
||||||
-- private Node class
|
-- private Node class
|
||||||
|
|
||||||
local nodesById = nil
|
local nodesById = nil
|
||||||
@ -43,12 +51,12 @@ local function findOrCreateDescendantNode(self, keys)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function invokeNodeCallbacks(self, params)
|
local function invokeNodeCallbacks(self, params)
|
||||||
local counter = 0
|
-- copy the hash into an array, for safety (self-erasures)
|
||||||
for _,callback in pairs(self.callbacks) do
|
local callbacks, count = hash2array(self.callbacks)
|
||||||
callback(unpack(params))
|
for i=1,#callbacks do
|
||||||
counter = counter + 1
|
callbacks[i](unpack(params))
|
||||||
end
|
end
|
||||||
return counter
|
return count
|
||||||
end
|
end
|
||||||
|
|
||||||
local function invokeAllNodeCallbacksInSubTree(self, params)
|
local function invokeAllNodeCallbacksInSubTree(self, params)
|
||||||
|
Loading…
Reference in New Issue
Block a user