Defer AceDB initialization until ADDON_LOADED to fix settings not persisting

CoA.db was created at file-load time, racing ahead of this client's
SavedVariables restoration and silently orphaning the profile table
from the real global before it ever got populated from disk.
This commit is contained in:
2026-07-16 16:26:18 +02:00
parent bf9972e624
commit fd2ee1903c
+10 -5
View File
@@ -28,8 +28,6 @@ local defaults = {
}, },
} }
CoA.db = AceDB:New("ElvUI_CoADB", defaults, true)
function CoA:RefreshConfig() function CoA:RefreshConfig()
if self.UpdateExtraActionButtonSize then self:UpdateExtraActionButtonSize() end if self.UpdateExtraActionButtonSize then self:UpdateExtraActionButtonSize() end
if self.UpdateInstanceButtonFont then self:UpdateInstanceButtonFont() end if self.UpdateInstanceButtonFont then self:UpdateInstanceButtonFont() end
@@ -37,9 +35,16 @@ function CoA:RefreshConfig()
if self.UpdateClassResourceVisibility then self:UpdateClassResourceVisibility() end if self.UpdateClassResourceVisibility then self:UpdateClassResourceVisibility() end
end end
CoA.db.RegisterCallback(CoA, "OnProfileChanged", "RefreshConfig") CoA:RegisterEvent("ADDON_LOADED", function(_, addon)
CoA.db.RegisterCallback(CoA, "OnProfileCopied", "RefreshConfig") if addon ~= AddOnName then return end
CoA.db.RegisterCallback(CoA, "OnProfileReset", "RefreshConfig") CoA:UnregisterEvent("ADDON_LOADED")
CoA.db = AceDB:New("ElvUI_CoADB", defaults, true)
CoA.db.RegisterCallback(CoA, "OnProfileChanged", "RefreshConfig")
CoA.db.RegisterCallback(CoA, "OnProfileCopied", "RefreshConfig")
CoA.db.RegisterCallback(CoA, "OnProfileReset", "RefreshConfig")
end)
local function getOptions() local function getOptions()
local profiles = AceDBOptions:GetOptionsTable(CoA.db) local profiles = AceDBOptions:GetOptionsTable(CoA.db)