AdiButtonAuras

AdiButtonAuras

404k Downloads

User Rules not working

Derangement opened this issue ยท 1 comments

commented

I've recently installed this addon (starting with version 1.8), and noticed that custom User Rules are being saved, but don't actually do anything.

This is because their builders aren't being properly added to the builder table.

Edit: proposed a change too soon. This was only working for me because I had already saved the user rules. My change would fix them actually doing something, but breaks saving. :(
Here's a suggested fix for this: replace line 82 of rules/UserRules.lua with the following code:

AdiButtonAuras:RegisterRules(function() return BuildUserRules() end)

Currently, that line erroneously reads:

AdiButtonAuras:RegisterRules(function() return BuildUserRules end)

(I am rather new to GitHub, Should this kind of bugfixes be done as pull requests, to streamline things on your end?)

commented

Okay, looks like the reason for the bug really was because of some confusion with the initializer / builders for User Rules. I was just too sleepy to figure out the right fix yesterday. ๐Ÿ˜›

If AdiButtonAuras:RegisterRules takes an initializer for an argument, and initializers return builders, then BuildUserRules is a builder.
Builders are supposed to add rules to addon.db.profile.rules, and their return value is irrelevant.

The correct fix, then, is to replace the return rules of line 79 in rules/UserRules.lua with:

for _, builder in ipairs(rules) do
    xpcall(builder, errorhandler)
end

I've played around with adding/deleting custom rules, reloading UI, and this time it doesn't break. ๐Ÿ˜‰