From ed3db25ff1dab06bd3bfaf050b776541b689a366 Mon Sep 17 00:00:00 2001 From: Salikh Gurgenidze Date: Sat, 3 Jan 2026 21:44:22 +0400 Subject: [PATCH] fix: category view, lock out items when in mail or trade --- Guda.toc | 2 +- UI/BagFrame.lua | 14 +++++++++++--- UI/FrameHelpers.lua | 18 +++++------------- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/Guda.toc b/Guda.toc index 6b01533..a7c193b 100644 --- a/Guda.toc +++ b/Guda.toc @@ -2,7 +2,7 @@ ## Title: Guda ## Notes: All-in-one bag and bank addon for World of Warcraft 1.12.1 (Turtle WoW) ## Author: Vati -## Version: 1.5.3 +## Version: 1.5.4 ## SavedVariables: Guda_DB ## SavedVariablesPerCharacter: Guda_CharDB diff --git a/UI/BagFrame.lua b/UI/BagFrame.lua index ae8779a..97ca212 100644 --- a/UI/BagFrame.lua +++ b/UI/BagFrame.lua @@ -324,7 +324,12 @@ function BagFrame:Update() -- Display items local viewType = addon.Modules.DB:GetSetting("bagViewType") or "single" - + + -- Clear itemButtons table before rebuilding (prevents stale references) + for k in pairs(itemButtons) do + itemButtons[k] = nil + end + -- Reset all section headers before displaying items local i = 1 while true do @@ -610,7 +615,8 @@ function BagFrame:DisplayItemsByCategory(bagData, isOtherChar, charName) local matchesFilter = self:PassesSearchFilter(itemData) Guda_ItemButton_SetItem(button, bagID, slot, itemData, false, isOtherChar and charName or nil, matchesFilter, isOtherChar) button.inUse = true - + table.insert(itemButtons, button) + col = col + 1 if col >= blockCols then col = 0 @@ -716,6 +722,7 @@ function BagFrame:DisplayItemsByCategory(bagData, isOtherChar, charName) -- Ensure it's not actually read-only for drop behavior (it should still receive clicks/drops) button.isReadOnly = false button.inUse = true + table.insert(itemButtons, button) else for _, item in ipairs(items) do local bagParent = self:GetBagParent(item.bagID) @@ -728,7 +735,8 @@ function BagFrame:DisplayItemsByCategory(bagData, isOtherChar, charName) button:Show() Guda_ItemButton_SetItem(button, item.bagID, item.slotID, item.itemData, false, isOtherChar and charName or nil, self:PassesSearchFilter(item.itemData), isOtherChar) button.inUse = true - + table.insert(itemButtons, button) + sCol = sCol + 1 if sCol >= blockCols then sCol = 0 diff --git a/UI/FrameHelpers.lua b/UI/FrameHelpers.lua index 91466da..08f8e5b 100644 --- a/UI/FrameHelpers.lua +++ b/UI/FrameHelpers.lua @@ -54,19 +54,11 @@ function Guda_UpdateLockStates(parentsTable) local buttons = { parent:GetChildren() } for _, button in ipairs(buttons) do if button.hasItem ~= nil and button:IsShown() and button.bagID and button.slotID then - local ok, name, texture, count, quality, canUse = pcall(function() return GetContainerItemInfo(button.bagID, button.slotID) end) - local _, _, locked = nil, nil, nil - if ok then - -- older GetContainerItemInfo returns texture, count, locked etc in different orders; try to call a safe wrapper if available - local infoOk, iName, iTexture, iCount, iQuality, iCanUse, iLocked = pcall(function() return GetContainerItemInfo(button.bagID, button.slotID) end) - if infoOk then - -- Try to find 'locked' boolean among returned values (best-effort) - for _, val in ipairs({iName, iTexture, iCount, iQuality, iCanUse, iLocked}) do - if type(val) == "boolean" then locked = val; break end - end - end - end - if not button.otherChar and not button.isReadOnly and SetItemButtonDesaturated and locked ~= nil then + -- GetContainerItemInfo returns: texture, itemCount, locked, quality, readable + -- The 3rd return value is the lock state (boolean or nil) + local _, _, locked = GetContainerItemInfo(button.bagID, button.slotID) + if not button.otherChar and not button.isReadOnly and SetItemButtonDesaturated then + -- locked can be true/1 (locked) or nil/false (unlocked) SetItemButtonDesaturated(button, locked, 0.5, 0.5, 0.5) end end