Fix color bug (Fix inside)
Hi,
the problem with your reset color bug is, that in
SDL.db.profile.general.colors[k] = v;
as v is a table, you are assigning a table. Thus, the next time you change your color, you do change the tables of SDL.db.profile.general.colors as well, because the are now the same. Fix is:
SDL.db.profile.general.colors[k] = SDL:shallowcopy(v);
where shallow copy is this function, see here http://lua-users.org/wiki/CopyTable :
function SDL:shallowcopy(orig)
local orig_type = type(orig)
local copy
if orig_type == 'table' then
copy = {}
for orig_key, orig_value in pairs(orig) do
copy[orig_key] = orig_value
end
else -- number, string, boolean, etc
copy = orig
end
return copy
end
Edited by Sven-Massard