Fixing crash-to-desktop bug with GetTradingHouseSearchResultItemLink

katkat42 [11-28-14 - 06:27]
Fixing crash-to-desktop bug with GetTradingHouseSearchResultItemLink
Filename
Common.lua
diff --git a/Common.lua b/Common.lua
index f017659..3d2327c 100644
--- a/Common.lua
+++ b/Common.lua
@@ -66,7 +66,7 @@ function SousChef.HookInventory()
 	ZO_ScrollList_RefreshVisible(BANK)
 	ZO_ScrollList_RefreshVisible(GUILD_BANK)
 	if not SousChef.settings.showOnClick then
-		ZO_PreHookHandler(ItemTooltip, "OnShow", function() zo_callLater(function() SousChef.AddDetails(moc()) end, 1000) end)
+		ZO_PreHookHandler(ItemTooltip, "OnShow", function() zo_callLater(function() SousChef.AddDetails(moc()) end, 500) end)
 		ZO_PreHookHandler(ItemTooltip, "OnUpdate", function() return SousChef.AddDetails(moc()) end)
 		ZO_PreHookHandler(ItemTooltip, "OnHide", function() rowClicked = nil return false end )
 	end
@@ -108,15 +108,16 @@ function SousChef.AddDetails(row)
 	local bagId = rowInfo.bagId or rowInfo.lootId
 	local slotIndex = rowInfo.slotIndex
 	if bagId == nil then
-		if slotIndex == nil then return end
+		if slotIndex == nil then return false end
 		bagId = slotIndex + 0
 		slotIndex = nil
 	end
 	local itemLink = (slotIndex and GetItemLink(bagId, slotIndex))
 		or (rowInfo.lootId and GetLootItemLink(bagId))
-		or (TRADING_HOUSE:IsAtTradingHouse() and TRADING_HOUSE.m_numItemsOnPage ~= 0 and GetTradingHouseSearchResultItemLink(bagId))
+		-- If there are no search results present in memory, GetTradingHouseSearchResultItemLink will crash to desktop
+		or (TRADING_HOUSE:IsAtTradingHouse() and TRADING_HOUSE.m_numItemsOnPage ~= nil and TRADING_HOUSE.m_numItemsOnPage ~= 0 and GetTradingHouseSearchResultItemLink(bagId))
 		or (GetStoreItemLink(bagId))
-	if itemLink == "" then return end
+	if itemLink == "" then return false end

 	-- item is a recipe
 	if GetItemLinkItemType(itemLink) == ITEMTYPE_RECIPE then