fix: guard InterfaceOptionsFrame HookScript, defer TankMode class resolve

On the CoA client the legacy InterfaceOptionsFrame global may be nil (the
reworked Settings panel does not always expose it). The unguarded
HookScript calls in Castbar.lua and ClassColours.lua then threw on
addon load. Wrap both in 'if InterfaceOptionsFrame then ... end',
mirroring the guard already present around InterfaceOptionsCombatPanel
in Castbar.lua. SetCVars() is still called unconditionally afterwards.

TankMode.lua resolved the player's class at file scope with
select(2, UnitClass('player')), which on CoA can run before
PLAYER_LOGIN — UnitClass returns nil and 'class' stays nil for the
whole session, breaking IsTank/IsHealer/Toggle. Move the assignment
into mod:OnEnable() (where it is already re-assigned) and leave the
file-scope local as nil. Also document that IsTank/IsHealer only know
about the vanilla 3.3.5 classes; CoA custom classes fall through to
DAMAGER until a CoA-aware tank/healer table is available.
This commit is contained in:
2026-05-24 17:38:00 +02:00
parent 69e975dc2e
commit 39370fcf98
3 changed files with 20 additions and 8 deletions
+2
View File
@@ -416,12 +416,14 @@ function mod:OnInitialize()
end
)
end
if InterfaceOptionsFrame then
InterfaceOptionsFrame:HookScript(
"OnHide",
function()
SetCVars()
end
)
end
SetCVars()
end
+2
View File
@@ -106,7 +106,9 @@ function mod:OnInitialize()
end
end)
end
if InterfaceOptionsFrame then
InterfaceOptionsFrame:HookScript("OnHide", function() SetCVars() end)
end
SetCVars()
end
function mod:OnEnable()
+9 -1
View File
@@ -8,7 +8,10 @@ local addon = LibStub("AceAddon-3.0"):GetAddon("KuiNameplates")
local mod = addon:NewModule("TankMode", addon.Prototype, "AceEvent-3.0")
local L = LibStub("AceLocale-3.0"):GetLocale("KuiNameplates")
local class, tankmode = select(2, UnitClass("player")), nil
-- `class` is resolved in mod:OnEnable() rather than at file scope: on the CoA
-- client this file can be parsed before PLAYER_LOGIN, when UnitClass("player")
-- returns nil and would otherwise leave `class` permanently nil.
local class, tankmode = nil, nil
local profile_tankmode
@@ -137,6 +140,10 @@ do
return tankTalents >= 3
end
-- NOTE: only vanilla 3.3.5 classes are matched below. CoA custom classes
-- will fall through to DAMAGER in mod:Update(). If a CoA-specific tank /
-- healer class table becomes available we should consult it here instead
-- of (or in addition to) the hard-coded class strings.
local function IsTank()
return (class == "WARRIOR" and select(3, GetTalentTabInfo(3)) >= 51) or
(class == "DEATHKNIGHT" and IsDeathKnightTank()) or
@@ -144,6 +151,7 @@ do
(class == "DRUID" and select(3, GetTalentTabInfo(2)) >= 51 and IsDruidTank())
end
-- See IsTank() note: CoA custom healer classes fall through to DAMAGER.
local function IsHealer()
return (class == "PALADIN" and select(3, GetTalentTabInfo(1)) >= 51) or
(class == "SHAMAN" and select(3, GetTalentTabInfo(3)) >= 51) or