Draper1 / MythicDungeonPortals

WoW Addon for Mythic Dungeon Portals
MIT License
4 stars 3 forks source link

Ensure Initialization of MythicDungeonPortalsSettings in addon:OnInitialize #5

Closed XanderCalvert closed 8 months ago

XanderCalvert commented 8 months ago

Issue: Encountered a nil value error when accessing MythicDungeonPortalsSettings.isMinimapEnabled in addon:OnInitialize. This issue arises due to MythicDungeonPortalsSettings not being initialized before its first use in some cases, particularly when the ADDON_LOADED event that triggers LoadDefaultSettings has not been processed yet.

Solution: Added a safety check in the addon:OnInitialize method to ensure MythicDungeonPortalsSettings is initialized as an empty table if it does not already exist. This prevents the nil value error and ensures stable functionality of the addon, even if LoadDefaultSettings has not yet run.

Rationale: This change ensures that the addon does not fail due to uninitialized settings, improving reliability. It also maintains the modular design of the addon by ensuring that default settings are handled within their respective initialization contexts.