Thread Tools Display Modes
Prev Previous Post   Next Post Next
09-17-17, 02:10 PM   #1
maqjav
A Theradrim Guardian
AddOn Author - Click to view addons
Join Date: Feb 2012
Posts: 60
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
 

WoWInterface » Developer Discussions » Lua/XML Help » AceDB lost default values on SetProfile


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off