Skip to content

Commit

Permalink
Fixed an item taint bug due to item frames being created mid combat.
Browse files Browse the repository at this point in the history
  • Loading branch information
Cidan committed Dec 5, 2023
1 parent 9150d2f commit 96d9250
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
4 changes: 4 additions & 0 deletions core/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ local const = addon:GetModule('Constants')
---@class Items: AceModule
local items = addon:GetModule('Items')

---@class ItemFrame: AceModule
local itemFrame = addon:GetModule('ItemFrame')

---@class Events: AceModule
local events = addon:GetModule('Events')

Expand Down Expand Up @@ -85,6 +88,7 @@ end

-- OnEnable is called when the addon is enabled.
function addon:OnEnable()
itemFrame:Enable()
sectionFrame:Enable()
masque:Enable()
context:Enable()
Expand Down
13 changes: 7 additions & 6 deletions frames/item.lua
Original file line number Diff line number Diff line change
Expand Up @@ -310,9 +310,13 @@ function itemFrame:OnEnable()
-- Pre-populate the pool with 300 items. This is done
-- so that items acquired during combat do not taint
-- the bag frame.
for _ = 1, 300 do
local item = self:Create()
item:Release()
---@type Item[]
local frames = {}
for i = 1, 300 do
frames[i] = self:Create()
end
for _, frame in pairs(frames) do
frame:Release()
end
end

Expand All @@ -327,7 +331,6 @@ function itemFrame:_DoCreate()
-- button textures are named after the button itself.
local name = format("BetterBagsItemButton%d", buttonCount)
buttonCount = buttonCount + 1

-- Create a hidden parent to the ItemButton frame to work around
-- item taint introduced in 10.x
local p = CreateFrame("Frame")
Expand Down Expand Up @@ -365,5 +368,3 @@ function itemFrame:Create()
---@return Item
return self._pool:Acquire()
end

itemFrame:Enable()

0 comments on commit 96d9250

Please sign in to comment.