fixed an edge case that I can not reproduce with tests

This commit is contained in:
Enrique García Cota 2012-01-30 00:07:12 +01:00
parent 624d4ce48e
commit 37eacc3a41

View File

@ -11,6 +11,14 @@ local function copy(t)
return c
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
local nodesById = nil
@ -43,12 +51,12 @@ local function findOrCreateDescendantNode(self, keys)
end
local function invokeNodeCallbacks(self, params)
local counter = 0
for _,callback in pairs(self.callbacks) do
callback(unpack(params))
counter = counter + 1
-- copy the hash into an array, for safety (self-erasures)
local callbacks, count = hash2array(self.callbacks)
for i=1,#callbacks do
callbacks[i](unpack(params))
end
return counter
return count
end
local function invokeAllNodeCallbacksInSubTree(self, params)