View Single Post
01-26-18, 04:21 PM   #14
gempir
A Black Drake
 
gempir's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2015
Posts: 84
UPDATE!

Okay so after debugging this for days now I've finally figure out the problem. Somehow Ace3's OnInitialize function does not work as expected. The official docs show this:

Lua Code:
  1. AceDBExample = LibStub("AceAddon-3.0"):NewAddon("AceDBExample")
  2.  
  3. function AceDBExample:OnInitialize()
  4.   self.db = LibStub("AceDB-3.0"):New("AceDBExampleDB")
  5. end

"AceDBExampleDB" is the saved var from the .toc file. I've done the same with my "gempDB" but I finally found out that it's nil at this point of the loading process.

I hacked together this quick fix:

Lua Code:
  1. function G.ace:OnInitialize()
  2.     local frame = CreateFrame("FRAME", "SavedVarsFrame");
  3.     frame:RegisterEvent("ADDON_LOADED")
  4.     frame:SetScript("OnEvent", function(self, event, arg1)
  5.         if arg1 == "gempUI" then
  6.             self:UnregisterEvent("ADDON_LOADED")
  7.             G.ace.db = LibStub("AceDB-3.0"):New("gempDB", defaults, true)
  8.             options.args.profiles = LibStub("AceDBOptions-3.0"):GetOptionsTable(G.ace.db)
  9.         end
  10.     end)
  11. [..]

and VOILA my config now saves correctly after reloading. The only Idea I have is that AceDB listens to the wrong ADDON_LOADED event? But I'm assuming the first argument of :NewAddon dictates the addon name, and that's what I have.

Lua Code:
  1. G.ace = LibStub("AceAddon-3.0"):NewAddon("gempUI", "AceConsole-3.0", "AceEvent-3.0")

So. Anyone an Idea what's going on? Should I maybe open an issue on their wowace page?
  Reply With Quote