View Single Post
09-04-20, 02:04 PM   #16
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,240
None of the following belongs in OnEnable():
Code:
self.db = LibStub("AceDB-3.0"):New("AMineDB", defaults) 	
self.profileOptions = LibStub("AceDBOptions-3.0"):GetOptionsTable(self.db);
LibStub("AceConfig-3.0"):RegisterOptionsTable("Profiles", self.profileOptions);

self.myOptions = LibStub("AceDBOptions-3.0"):GetOptionsTable(myOptionsTable);
LibStub("AceConfig-3.0"):RegisterOptionsTable(THISAP, myOptionsTable);	
self.myOptions.general = LibStub("AceConfigDialog-3.0"):AddToBlizOptions(THISAP, nil, nil,"general")  
self.myOptions.buh = LibStub("AceConfigDialog-3.0"):AddToBlizOptions(THISAP, "buh", THISAP, "spellsels");
self.profilesFrame = LibStub("AceConfigDialog-3.0"):AddToBlizOptions("Profiles", "Profiles", THISAP);
It should ALL be done in OnInitialize(). You only create that stuff once, whereas OnEnable() is fired whenever the addon is enabled, which could mean after OnDisable just as much as when the addon is first run.

Further, if the addon is set to disabled on first run by the user, then the above code will never get called, and you will have a database that is never built, and so MyAddOn.db is nil.
  Reply With Quote