ElvUI-TBC / ElvUI

ElvUI for World of Warcraft - The Burning Crusade (2.4.3)
https://discord.gg/UXSc7nt
104 stars 24 forks source link

Bugfix: Don't crash when frames lack castbar table #467

Closed Arcitec closed 5 years ago

Arcitec commented 5 years ago

The code assumed that every frame always had a "castbar" table, and then it checked "if db.castbar.enable"... (db = the frame's table).

That failed and caused Lua errors (and aborted the profile loading) since the "castbar" table does not always exist, thus causing an "attempt to access nil field" error.

Fixed to first verify that a "castbar" table exists before attempting to check if the "enable" property exists!


Here's a typical example of a unitframe with no "castbar" table:

    ["player"] = {
            ["swingbar"] = {
                    ["color"] = {
                            ["b"] = 0.6470588235294118,
                            ["g"] = 0.6,
                            ["r"] = 0.1686274509803922,
                    },
                    ["text"] = {
                            ["font"] = "PT Sans Narrow",
                            ["fontSize"] = 14,
                            ["fontOutline"] = "OUTLINE",
                    },
            },
            ["aurabar"] = {
                    ["maxBars"] = 4,
            },
            ["power"] = {
                    ["height"] = 14,
            },
            ["raidicon"] = {
                    ["attachTo"] = "RIGHT",
                    ["size"] = 26,
                    ["xOffset"] = 29,
                    ["yOffset"] = 12,
            },
    },