p3lim-wow / Wasabi

Library for implementing addon configs
Other
6 stars 1 forks source link

Attempt to index global 'FramesDB' (a nil value) #4

Closed kaytotes closed 6 years ago

kaytotes commented 6 years ago

I've been having in issue with Wasabi db7f114 for a short while but trying to finally tackle it now. In my addon Improved Blizzard UI I use Wasabi for the configuration.

I've been having an issue that only affects new users or when I add a new configuration option. Essentially due to them not having the saved variables any checks towards them are attempting to access a nil global and failing, doing a /reload (after the variables have been created) resolves the issue going forwards. At least until a new option is added.

I'm unsure if this is a bug or an implementation issue / misunderstanding on my part. How best should I be handling ensuring this can't be nil and deferring until they're set?

Here is an error message I'm getting however plenty are generated on first load.

3x ...ddOns\ImprovedBlizzardUI\modules\frames\killfeed.lua:170: attempt to index global 'FramesDB' (a nil value)
...ddOns\ImprovedBlizzardUI\modules\frames\killfeed.lua:170: in function <...ddOns\ImprovedBlizzardUI\modules\frames\killfeed.lua:167>

Locals:
event = "ADDON_LOADED"
(*temporary) = "attempt to index global 'FramesDB' (a nil value)"
KillFeed_Update = <function> defined @ImprovedBlizzardUI\modules\frames\killfeed.lua:55

This directly coincides with this line of code which makes sense to me because obviously it's before any addon loaded events etc. However in the same file during these lines I am waiting for addon loaded and yet this errors too.

Could you possibly advise on best practices for this situation if at all possible?

p3lim commented 6 years ago

Obviously, SV are not loaded until the addon is completely loaded (ADDON_LOADED event), so the DB will never be populated before that point. That is your error.

However, there's an error on Wasabi's end too. Since Wasabi doesn't necessarily know the name of the addon using it, all SV are loaded in during PLAYER_LOGIN as it fires when ALL addons are loaded. This is something I obviously need to fix (easy when Wasabi is embedded, not as easy when not, I'll have to investigate).

As a temporary fix you can trigger the event handler of the panel using something like this:

if(event == 'ADDON_LOADED' and ... == addOnName) then
    MyPanel:GetScript('OnEvent')(MyPanel, 'PLAYER_LOGIN')
    ...
end

I'll try and get a new version out with a fix on monday.

kaytotes commented 6 years ago

Brilliant thank you for that information. Now that I know the actual behaviour of Wasabi, and with your workaround, I should be able to figure out a solution to this.

On Sun, 12 Aug 2018, 14:42 Adrian L Lange, notifications@github.com wrote:

Since Wasabi doesn't necessarily know the name of the addon, all SV are loaded in during PLAYER_LOGIN. This is something I obviously need to fix (easy when Wasabi is embedded, not as easy when not, I'll have to investigate).

As a temporary fix you can trigger the event handler of the panel using something like this:

if(event == 'ADDON_LOADED' and ... == addOnName) then MyPanel:GetScript('OnEvent')(MyPanel, 'PLAYER_LOGIN') ...end

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/p3lim-wow/Wasabi/issues/4#issuecomment-412343747, or mute the thread https://github.com/notifications/unsubscribe-auth/AHLaBgru_rBSdhxYYBB4mqkMXeyoaVUjks5uQDC0gaJpZM4V5Waa .