Thread: AceDB Resetting
View Single Post
08-08-16, 09:40 AM   #15
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by MilleXIV View Post
Also, just had a flash of memory. This is the commit after which things stopped working: https://github.com/MilleXIV/XIV_Data...214a286bc1840b. My only guess with this is the inclusion of AceEvent?
At a glance I don't see anything in there that would affect AceDB, but:

1. Forcing the Blizzard_TradeSkillUI to load isn't optimal. All the API functions to get data about your character's trade skills and recipes should be available and fully functional without loading the UI. If your addon is modifying the UI (I didn't actually check) then it would be better to delay that part of your addon until the UI is loaded naturally. Listen for ADDON_LOADED where arg1 is "Blizzard_TradeSkillUI".

2. While it doesn't affect functionality, organizing your code a little better will help you (and anyone else reading it) keep track of what's going on in the future. For example, here you're randomly mixing RegisterEvent and SetScript lines. It would be easier to tell, at a glance, what all is happening there if you put all the RegisterEvent lines together, and all the SetScript lines together.

3. What on earth is going on here? Rather than having one (named) function that just creates and returns another (anonymous) function that's always the same (eg. it doesn't change depending on what's passed to the wrapper function, or on any other variables or conditions), just name that inner function and refer to it, rather than wrapping it and calling the wrapper to get the reference. Actually, since it looks like you only call each wrapper once to get the inner function to set it as an OnClick hander, you should just use the inner function (anonymously) directly in the SetScript call:

Code:
self.frames.chat:SetScript('OnClick', function(self, button, down)
    if InCombatLockdown() then return; end
        if button == "LeftButton" then
            ChatFrame_OpenMenu()
        end
    end
end)
4. Similar to #2, you should avoid mixing tabs and spaces in your indentation, and if you use spaces (why) make sure you're using them consistently (eg. each level of indentation is always 4 spaces, not 4 here and 3 there and 5 over there). I only noticed #3 because it looked like you were missing an end statement, but on closer inspection, it turned out your indentation was just weird.

As for the original problem, do you have an error display installed? While the built-in error display has gotten a little better over the years, it's still sadly lacking in some essential features, like the ability to show you errors that happen during the initial loading process (which is where many of your errors will occur during development).
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote