Skip to content
Snippets Groups Projects
Commit d5aa245b authored by dg's avatar dg
Browse files

Fix random/rare crash when saving

git-svn-id: http://svn.net-core.org/repos/t-engine4@2064 51575b47-30f0-44d4-a5cc-537603b46e54
parent dfcc8f66
No related branches found
No related tags found
No related merge requests found
......@@ -112,10 +112,34 @@ function _M:clone(t)
return n
end
local function clonerecursfull(clonetable, d)
local nb = 0
local add
local n = {}
clonetable[d] = n
for k, e in pairs(d) do
local nk, ne = k, e
if clonetable[k] then nk = clonetable[k]
elseif type(k) == "table" then nk, add = clonerecursfull(clonetable, k) nb = nb + add
end
if clonetable[e] then ne = clonetable[e]
elseif type(e) == "table" and (type(k) ~= "string" or k ~= "__threads") then ne, add = clonerecursfull(clonetable, e) nb = nb + add
end
n[nk] = ne
end
setmetatable(n, getmetatable(d))
if n.cloned and n.__CLASSNAME then n:cloned(d) end
if n.__CLASSNAME then nb = nb + 1 end
return n, nb
end
--- Clones the object, all subobjects without cloning twice a subobject
-- @return the clone and the number of cloned objects
function _M:cloneFull()
return core.serial.cloneFull(self)
local clonetable = {}
return clonerecursfull(clonetable, self)
end
--- Replaces the object with an other, by copying (not deeply)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment