QuestieOptionsArrow: guard LibSharedMedia HashTable call - LSM is OptionalDep, may not be present or have font type registered at load time

This commit is contained in:
Xurkon
2026-04-24 03:59:33 -05:00
parent 822b6a5c3f
commit 97c8f60a28
@@ -13,15 +13,20 @@ local QuestieTracker = QuestieLoader:ImportModule("QuestieTracker")
---@type l10n ---@type l10n
local l10n = QuestieLoader:ImportModule("l10n") local l10n = QuestieLoader:ImportModule("l10n")
local SharedMedia = LibStub("LibSharedMedia-3.0") local SharedMedia = LibStub and LibStub("LibSharedMedia-3.0", true)
-- Build expanded font list from SharedMedia + common WoW fonts -- Build expanded font list from SharedMedia + common WoW fonts
local function GetExpandedFontList() local function GetExpandedFontList()
local fonts = {} local fonts = {}
-- Add SharedMedia fonts (HashTable returns key-value table) -- Add SharedMedia fonts if available (HashTable returns nil if media type not registered yet)
for name, _ in pairs(SharedMedia:HashTable("font")) do if SharedMedia and SharedMedia.HashTable then
local lsmFonts = SharedMedia:HashTable("font")
if lsmFonts then
for name, _ in pairs(lsmFonts) do
fonts[name] = name fonts[name] = name
end end
end
end
-- Add common WoW fonts not typically in SharedMedia -- Add common WoW fonts not typically in SharedMedia
local wowFonts = { local wowFonts = {
["Friz Quadrata TT"] = true, ["Friz Quadrata TT"] = true,
@@ -116,7 +121,7 @@ function QuestieOptions.tabs.arrow:Initialize()
type = "select", type = "select",
dialogControl = 'LSM30_Font', dialogControl = 'LSM30_Font',
order = 7, order = 7,
values = GetExpandedFontList(), values = function() return GetExpandedFontList() end,
style = 'dropdown', style = 'dropdown',
name = function() return l10n("Arrow Font") end, name = function() return l10n("Arrow Font") end,
desc = function() return l10n("The font used for the arrow distance and title text.") end, desc = function() return l10n("The font used for the arrow distance and title text.") end,