From a2a325c8ab388c93300385a369bef7f0f50f8312 Mon Sep 17 00:00:00 2001 From: Xurkon Date: Fri, 24 Apr 2026 04:24:38 -0500 Subject: [PATCH] Guard all LibSharedMedia-3.0 usages against nil LSM - OptionalDep may not load - Use LibStub(..., true) silent flag on all LSM acquisition sites - Guard HashTable() calls in Options files (returns nil if no font type registered) - Guard all Fetch() call sites with inline 'LSM30 and LSM30:Fetch() or fallback' - Make font values lazy functions in options dropdowns so LSM has time to register - Affects: QuestieOptionsTracker, QuestieOptionsArrow, QuestieArrow, QuestieTracker, TrackerHeaderFrame, TrackerLinePool, TrackerQuestTimers --- Modules/Arrow/QuestieArrow.lua | 4 ++-- .../Options/TrackerTab/QuestieOptionsTracker.lua | 13 +++++++++---- Modules/Tracker/QuestieTracker.lua | 4 ++-- Modules/Tracker/TrackerHeaderFrame.lua | 4 ++-- Modules/Tracker/TrackerLinePool.lua | 10 +++++----- Modules/Tracker/TrackerQuestTimers.lua | 4 ++-- 6 files changed, 22 insertions(+), 17 deletions(-) diff --git a/Modules/Arrow/QuestieArrow.lua b/Modules/Arrow/QuestieArrow.lua index 88d0e3a..92917bc 100644 --- a/Modules/Arrow/QuestieArrow.lua +++ b/Modules/Arrow/QuestieArrow.lua @@ -17,7 +17,7 @@ local QuestiePlayer = QuestieLoader:ImportModule("QuestiePlayer") local QuestieQuest = QuestieLoader:ImportModule("QuestieQuest") local HBD = QuestieCompat.HBD or LibStub("HereBeDragonsQuestie-2.0") -local SharedMedia = LibStub("LibSharedMedia-3.0") +local SharedMedia = LibStub and LibStub("LibSharedMedia-3.0", true) local atan2 = math.atan2 local pi = math.pi @@ -807,7 +807,7 @@ function QuestieArrow:UpdateFont() if not arrowFrame then return end local fontSize = Questie.db.profile.arrowFontSize or 10 local fontName = Questie.db.profile.arrowFont or "Friz Quadrata TT" - local fontFace = SharedMedia:Fetch("font", fontName) or fontName + local fontFace = (SharedMedia and SharedMedia.Fetch and SharedMedia:Fetch("font", fontName)) or fontName if arrowFrame.title then arrowFrame.title:SetFont(fontFace, fontSize, "OUTLINE") end diff --git a/Modules/Options/TrackerTab/QuestieOptionsTracker.lua b/Modules/Options/TrackerTab/QuestieOptionsTracker.lua index b99924a..b611bc9 100644 --- a/Modules/Options/TrackerTab/QuestieOptionsTracker.lua +++ b/Modules/Options/TrackerTab/QuestieOptionsTracker.lua @@ -27,14 +27,19 @@ QuestieOptions.tabs.tracker = { ... } local _GetShortcuts local trackerOptions = {} -local SharedMedia = LibStub("LibSharedMedia-3.0") +local SharedMedia = LibStub and LibStub("LibSharedMedia-3.0", true) -- Build expanded font list from SharedMedia + common WoW fonts local function GetExpandedFontList() local fonts = {} - -- Add SharedMedia fonts (HashTable returns key-value table) - for name, _ in pairs(SharedMedia:HashTable("font")) do - fonts[name] = name + -- Add SharedMedia fonts if available (HashTable returns nil if media type not registered yet) + if SharedMedia and SharedMedia.HashTable then + local lsmFonts = SharedMedia:HashTable("font") + if lsmFonts then + for name, _ in pairs(lsmFonts) do + fonts[name] = name + end + end end -- Add common WoW fonts not typically in SharedMedia local wowFonts = { diff --git a/Modules/Tracker/QuestieTracker.lua b/Modules/Tracker/QuestieTracker.lua index f640510..03c879b 100644 --- a/Modules/Tracker/QuestieTracker.lua +++ b/Modules/Tracker/QuestieTracker.lua @@ -48,7 +48,7 @@ local GetQuestLogTitle = QuestieCompat.GetQuestLogTitle local GetQuestLogIndexByID = QuestieCompat.GetQuestLogIndexByID local GetItemInfo = QuestieCompat.GetItemInfo -local LSM30 = LibStub("LibSharedMedia-3.0") +local LSM30 = LibStub and LibStub("LibSharedMedia-3.0", true) -- Local Vars local trackerLineWidth = 0 @@ -1275,7 +1275,7 @@ function QuestieTracker:Update() line.label:SetPoint("TOPLEFT", line, "TOPLEFT", lineWidthQBC, 0) -- Set Timer font - line.label:SetFont(LSM30:Fetch("font", Questie.db.profile.trackerFontObjective), + line.label:SetFont(LSM30 and LSM30:Fetch("font", Questie.db.profile.trackerFontObjective) or Questie.db.profile.trackerFontObjective, Questie.db.profile.trackerFontSizeObjective, Questie.db.profile.trackerFontOutline) -- Set Timer Title based on states diff --git a/Modules/Tracker/TrackerHeaderFrame.lua b/Modules/Tracker/TrackerHeaderFrame.lua index 27403ce..b564951 100644 --- a/Modules/Tracker/TrackerHeaderFrame.lua +++ b/Modules/Tracker/TrackerHeaderFrame.lua @@ -26,7 +26,7 @@ local QuestieQuest = QuestieLoader:ImportModule("QuestieQuest") local QuestieCombatQueue = QuestieLoader:ImportModule("QuestieCombatQueue") ---@type l10n local l10n = QuestieLoader:ImportModule("l10n") -local LSM30 = LibStub("LibSharedMedia-3.0") +local LSM30 = LibStub and LibStub("LibSharedMedia-3.0", true) --- COMPATIBILITY --- local C_QuestLog = QuestieCompat.C_QuestLog @@ -209,7 +209,7 @@ function TrackerHeaderFrame:Update() headerFrame.questieIcon:SetPoint("TOPLEFT", headerFrame, "TOPLEFT", 6, 0) headerFrame.questieIcon:Show() - headerFrame.trackedQuests.label:SetFont(LSM30:Fetch("font", Questie.db.profile.trackerFontHeader), trackerFontSizeHeader, Questie.db.profile.trackerFontOutline) + headerFrame.trackedQuests.label:SetFont(LSM30 and LSM30:Fetch("font", Questie.db.profile.trackerFontHeader) or Questie.db.profile.trackerFontHeader, trackerFontSizeHeader, Questie.db.profile.trackerFontOutline) local maxQuestAmount = "/" .. C_QuestLog.GetMaxNumQuestsCanAccept() local _, activeQuests = GetNumQuestLogEntries() diff --git a/Modules/Tracker/TrackerLinePool.lua b/Modules/Tracker/TrackerLinePool.lua index 94a5114..a8e67da 100644 --- a/Modules/Tracker/TrackerLinePool.lua +++ b/Modules/Tracker/TrackerLinePool.lua @@ -37,7 +37,7 @@ local C_QuestLog = QuestieCompat.C_QuestLog local GetQuestLogIndexByID = QuestieCompat.GetQuestLogIndexByID local LibDropDown = QuestieCompat.LibUIDropDownMenu or LibStub:GetLibrary("LibUIDropDownMenuQuestie-4.0") -local LSM30 = LibStub("LibSharedMedia-3.0") +local LSM30 = LibStub and LibStub("LibSharedMedia-3.0", true) local linePoolSize = 250 local lineIndex = 0 @@ -562,7 +562,7 @@ function TrackerLinePool.Initialize(questFrame) -- Charges Updates self.count:Hide() - self.count:SetFont(LSM30:Fetch("font", Questie.db.profile.trackerFontQuest), Questie.db.profile.trackerFontSizeQuest, "OUTLINE") + self.count:SetFont(LSM30 and LSM30:Fetch("font", Questie.db.profile.trackerFontQuest) or Questie.db.profile.trackerFontQuest, Questie.db.profile.trackerFontSizeQuest, "OUTLINE") if self.charges > 1 then self.count:SetText(self.charges) self.count:Show() @@ -1089,16 +1089,16 @@ TrackerLinePool.SetMode = function(self, mode) self.mode = mode if mode == "zone" then local trackerFontSizeZone = Questie.db.profile.trackerFontSizeZone - self.label:SetFont(LSM30:Fetch("font", Questie.db.profile.trackerFontZone), trackerFontSizeZone, Questie.db.profile.trackerFontOutline) + self.label:SetFont(LSM30 and LSM30:Fetch("font", Questie.db.profile.trackerFontZone) or Questie.db.profile.trackerFontZone, trackerFontSizeZone, Questie.db.profile.trackerFontOutline) self.label:SetHeight(trackerFontSizeZone) elseif mode == "quest" or mode == "achieve" then local trackerFontSizeQuest = Questie.db.profile.trackerFontSizeQuest - self.label:SetFont(LSM30:Fetch("font", Questie.db.profile.trackerFontQuest), trackerFontSizeQuest, Questie.db.profile.trackerFontOutline) + self.label:SetFont(LSM30 and LSM30:Fetch("font", Questie.db.profile.trackerFontQuest) or Questie.db.profile.trackerFontQuest, trackerFontSizeQuest, Questie.db.profile.trackerFontOutline) self.label:SetHeight(trackerFontSizeQuest) self.button = nil elseif mode == "objective" then local trackerFontSizeObjective = Questie.db.profile.trackerFontSizeObjective - self.label:SetFont(LSM30:Fetch("font", Questie.db.profile.trackerFontObjective), trackerFontSizeObjective, Questie.db.profile.trackerFontOutline) + self.label:SetFont(LSM30 and LSM30:Fetch("font", Questie.db.profile.trackerFontObjective) or Questie.db.profile.trackerFontObjective, trackerFontSizeObjective, Questie.db.profile.trackerFontOutline) self.label:SetHeight(trackerFontSizeObjective) end end diff --git a/Modules/Tracker/TrackerQuestTimers.lua b/Modules/Tracker/TrackerQuestTimers.lua index 4d4398a..f3b4ac6 100644 --- a/Modules/Tracker/TrackerQuestTimers.lua +++ b/Modules/Tracker/TrackerQuestTimers.lua @@ -16,7 +16,7 @@ local QuestieCombatQueue = QuestieLoader:ImportModule("QuestieCombatQueue") --- COMPATIBILITY --- local GetQuestLogIndexByID = QuestieCompat.GetQuestLogIndexByID -local LSM30 = LibStub("LibSharedMedia-3.0") +local LSM30 = LibStub and LibStub("LibSharedMedia-3.0", true) local WatchFrame = QuestTimerFrame or WatchFrame local blizzardTimerLocation = {} @@ -163,7 +163,7 @@ function TrackerQuestTimers:UpdateTimerFrame() local timeRemainingString, timeRemaining = TrackerQuestTimers:GetRemainingTimeByQuestId(timer.questId) if timeRemainingString ~= nil then Questie:Debug(Questie.DEBUG_SPAM, "[TrackerQuestTimers:UpdateTimerFrame] - ", timeRemainingString) - timer.frame.label:SetFont(LSM30:Fetch("font", Questie.db.profile.trackerFontObjective), Questie.db.profile.trackerFontSizeObjective, Questie.db.profile.trackerFontOutline) + timer.frame.label:SetFont(LSM30 and LSM30:Fetch("font", Questie.db.profile.trackerFontObjective) or Questie.db.profile.trackerFontObjective, Questie.db.profile.trackerFontSizeObjective, Questie.db.profile.trackerFontOutline) timer.frame.label:SetText(Questie:Colorize(timeRemainingString, "blue")) timer.frame:SetWidth(timer.frame.label:GetWidth() + ((34) - (18 - Questie.db.profile.trackerFontSizeQuest)) + Questie.db.profile.trackerFontSizeQuest) else