From fd2ee1903c302fbf49a3d8b9896ed9b8025ece32 Mon Sep 17 00:00:00 2001 From: Narcasung Date: Thu, 16 Jul 2026 16:26:18 +0200 Subject: [PATCH] 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. --- core.lua | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/core.lua b/core.lua index c1cdc53..2b912e7 100644 --- a/core.lua +++ b/core.lua @@ -28,8 +28,6 @@ local defaults = { }, } -CoA.db = AceDB:New("ElvUI_CoADB", defaults, true) - function CoA:RefreshConfig() if self.UpdateExtraActionButtonSize then self:UpdateExtraActionButtonSize() end if self.UpdateInstanceButtonFont then self:UpdateInstanceButtonFont() end @@ -37,9 +35,16 @@ function CoA:RefreshConfig() if self.UpdateClassResourceVisibility then self:UpdateClassResourceVisibility() end end -CoA.db.RegisterCallback(CoA, "OnProfileChanged", "RefreshConfig") -CoA.db.RegisterCallback(CoA, "OnProfileCopied", "RefreshConfig") -CoA.db.RegisterCallback(CoA, "OnProfileReset", "RefreshConfig") +CoA:RegisterEvent("ADDON_LOADED", function(_, addon) + if addon ~= AddOnName then return end + 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 profiles = AceDBOptions:GetOptionsTable(CoA.db)