Quantcast
WoWInterface - View Single Post - AceDB lost default values on SetProfile
View Single Post
09-17-17, 02:10 PM   #1
maqjav
A Cyclonian
Join Date: Feb 2012
Posts: 49
AceDB lost default values on SetProfile

Hello.

I'm trying to use profiles in one of my addons and everything works fine until I change the profile, where I lose every default value.

Let's say I have the next code:

Code:
local PROFILE_DEFAULTS = { 
  profile = {
    defaultValue = true, 
    anotherValue = "default"
  } 
}

function MyAddon:OnInitialize()
   self.db = LibStub("AceDB-3.0"):New("MyAddonDB", PROFILE_DEFAULTS)
   private.db = self.db
end

Now I change some settings where I change the value of "anotherValue" to "changed".
When I logout, I can see in my savedVariables.lua the next table:
Code:
["profileKeys"] = {
	["myCharacter"] = "profile1",
},
["profiles"] = {
	["profile1"] = {
		["anotherValue"] = "changed"
	}
},
If I try to set this profile to a second character, I get the next values:
Code:
private.db:SetProfile("profile1")

print(private.db.profile.anotherValue) --prints changed
print(private.db.profile.defaultValue) --prints nil
Somehow after changing the profile my default values are lost.
If I reset the UI then everything works again, and I have both values.

I tried using AceDBOptions, and I get the same result.

Am I doing something wrong in here?
Thanks.

Last edited by maqjav : 09-17-17 at 02:16 PM.
  Reply With Quote