Quantcast

fixing TradeSKillFrame = nil

Ignifazius [09-03-15 - 21:29]
fixing TradeSKillFrame = nil

it seems, if you haven't opened the profession window, the TradeSkillFrame
simply doesnt exist. If you found another item with ID = 0 this would case
a lua-error, saying the TradeSkillFrame is nil. Solution: just check if it
is already there. IMPORTANT: first check if nil, THEN check if visible
Filename
BagSync.lua
diff --git a/BagSync.lua b/BagSync.lua
index e6f1c39..35deb60 100644
--- a/BagSync.lua
+++ b/BagSync.lua
@@ -834,7 +834,7 @@ end
 local function AddItemToTooltip(frame, link) --workaround
 	if (link) then
 		local itemId = tonumber(string.match(link, "item:(%d+):"))	-- get itemID // itemID seems to be "0" for every reagent in profession window?!
-		if (itemId == 0 and TradeSkillFrame:IsVisible()) then -- some other frames show ID = 0 aswell, so limit this workaround to the profession window
+		if (itemId == 0 and TradeSkillFrame ~= nil and TradeSkillFrame:IsVisible()) then -- some other frames show ID = 0 aswell, so limit this workaround to the profession window || IMPORTANT: TradeSkillFrame ~= nil has to be checked BEFORE TradeSkillFrame:IsVisible()
 			local newItemId
 			if ((GetMouseFocus():GetName()) == "TradeSkillSkillIcon") then 			--replace TradeSkill
 				newItemId = tonumber(GetTradeSkillItemLink(TradeSkillFrame.selectedSkill):match("item:(%d+):"))