From 2d9d83f265c37b1d67a918b0325aecde2f2ee25c Mon Sep 17 00:00:00 2001 From: Xurkon Date: Sun, 29 Mar 2026 11:56:41 -0500 Subject: [PATCH] Fix: Add defensive nil checks for icon:UpdateCoord() calls in LibDBIcon --- Libs/LibDBIcon-1.0/LibDBIcon-1.0.lua | 34 ++++++++++++++++++---------- 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/Libs/LibDBIcon-1.0/LibDBIcon-1.0.lua b/Libs/LibDBIcon-1.0/LibDBIcon-1.0.lua index 9cf1d72..ebe1262 100644 --- a/Libs/LibDBIcon-1.0/LibDBIcon-1.0.lua +++ b/Libs/LibDBIcon-1.0/LibDBIcon-1.0.lua @@ -24,19 +24,21 @@ local isDraggingButton = false function lib:IconCallback(event, name, key, value) if lib.objects[name] then + local icon = lib.objects[name].icon + if not icon then return end if key == "icon" then - lib.objects[name].icon:SetTexture(value) + icon:SetTexture(value) elseif key == "iconCoords" then - lib.objects[name].icon:UpdateCoord() + if icon.UpdateCoord then icon:UpdateCoord() end elseif key == "iconR" then - local _, g, b = lib.objects[name].icon:GetVertexColor() - lib.objects[name].icon:SetVertexColor(value, g, b) + local _, g, b = icon:GetVertexColor() + icon:SetVertexColor(value, g, b) elseif key == "iconG" then - local r, _, b = lib.objects[name].icon:GetVertexColor() - lib.objects[name].icon:SetVertexColor(r, value, b) + local r, _, b = icon:GetVertexColor() + icon:SetVertexColor(r, value, b) elseif key == "iconB" then - local r, g = lib.objects[name].icon:GetVertexColor() - lib.objects[name].icon:SetVertexColor(r, g, value) + local r, g = icon:GetVertexColor() + icon:SetVertexColor(r, g, value) end end end @@ -147,12 +149,16 @@ end local function onMouseDown(self) self.isMouseDown = true - self.icon:UpdateCoord() + if self.icon and self.icon.UpdateCoord then + self.icon:UpdateCoord() + end end local function onMouseUp(self) self.isMouseDown = false - self.icon:UpdateCoord() + if self.icon and self.icon.UpdateCoord then + self.icon:UpdateCoord() + end end do @@ -176,7 +182,9 @@ do function onDragStart(self) self:LockHighlight() self.isMouseDown = true - self.icon:UpdateCoord() + if self.icon and self.icon.UpdateCoord then + self.icon:UpdateCoord() + end self:SetScript("OnUpdate", onUpdate) isDraggingButton = true lib.tooltip:Hide() @@ -192,7 +200,9 @@ end local function onDragStop(self) self:SetScript("OnUpdate", nil) self.isMouseDown = false - self.icon:UpdateCoord() + if self.icon and self.icon.UpdateCoord then + self.icon:UpdateCoord() + end self:UnlockHighlight() isDraggingButton = false for _, button in next, lib.objects do