From a643408db07b4390a39492cde7aa20fcfec11b03 Mon Sep 17 00:00:00 2001 From: Steven Jackson Date: Thu, 3 Jul 2014 13:13:13 -0500 Subject: [PATCH] database changes --- Interface/AddOns/SVUI/system/classes/Database.lua | 52 ++++++++++----------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/Interface/AddOns/SVUI/system/classes/Database.lua b/Interface/AddOns/SVUI/system/classes/Database.lua index bba2148..982050b 100644 --- a/Interface/AddOns/SVUI/system/classes/Database.lua +++ b/Interface/AddOns/SVUI/system/classes/Database.lua @@ -3356,14 +3356,16 @@ local function tablecopy(d, s) if type(s) ~= "table" then return end if type(d) == "table" then for k, v in pairs(s) do - if type(v) == "table" then - if not rawget(d, k) then rawset(d, k, {}) end - if type(d[k]) == "table" then - tablecopy(d[k], v) - end - else - if rawget(d, k) == nil then - rawset(d, k, v) + if(k ~= "SAFEDATA") then + if type(v) == "table" then + if not rawget(d, k) then rawset(d, k, {}) end + if type(d[k]) == "table" then + tablecopy(d[k], v) + end + else + if rawget(d, k) == nil then + rawset(d, k, v) + end end end end @@ -3462,22 +3464,24 @@ local function removeprofile(t, key) if(globals.profileKeys[key]) then globals.profileKeys[key] = nil end end -local function SanitizeDatabase(t) - local sv = rawget(t, "profile") - local src = rawget(t, "defaults") - for k,v in pairs(sv) do - if(k ~= "SAFEDATA") then - if(rawget(src, k)) then - for key in pairs(sv[k]) do - if not next(sv[k][key]) then - sv[k][key] = nil +local SanitizeDatabase = function(self, event) + if event == "PLAYER_LOGOUT" then + local sv = _G["SVUI_Profile"] + local src = DatabaseDefaults + for k,v in pairs(sv) do + if(k ~= "SAFEDATA") then + if(rawget(src, k)) then + for key in pairs(sv[k]) do + if not next(sv[k][key]) then + sv[k][key] = nil + end end - end - if not next(sv[k]) then + if not next(sv[k]) then + sv[k] = nil + end + else sv[k] = nil end - else - sv[k] = nil end end end @@ -3514,11 +3518,7 @@ local METAPROFILE = function(sv, pkey) local logout = CreateFrame("Frame",nil) logout:RegisterEvent("PLAYER_LOGOUT") - logout:SetScript("OnEvent", function(self, event) - if event == "PLAYER_LOGOUT" then - SanitizeDatabase(SuperVillain.db) - end - end) + logout:SetScript("OnEvent", SanitizeDatabase) return db end -- 1.7.9.5