From 96d925087bd10dd114cc4f2764c5d5813dba990f Mon Sep 17 00:00:00 2001 From: Antonio Lobato Date: Mon, 4 Dec 2023 19:53:20 -0800 Subject: [PATCH] Fixed an item taint bug due to item frames being created mid combat. --- core/init.lua | 4 ++++ frames/item.lua | 13 +++++++------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/core/init.lua b/core/init.lua index cbdbe440..61ab2407 100644 --- a/core/init.lua +++ b/core/init.lua @@ -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') @@ -85,6 +88,7 @@ end -- OnEnable is called when the addon is enabled. function addon:OnEnable() + itemFrame:Enable() sectionFrame:Enable() masque:Enable() context:Enable() diff --git a/frames/item.lua b/frames/item.lua index 778f1875..3477ef44 100644 --- a/frames/item.lua +++ b/frames/item.lua @@ -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 @@ -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") @@ -365,5 +368,3 @@ function itemFrame:Create() ---@return Item return self._pool:Acquire() end - -itemFrame:Enable()