Skip to content

Commit 4f97c04

Browse files
github-actions[bot]LocalIdentityLocalIdentity
authored
[pob2-port] Fix crash on hovering over legacy shared items (#9901)
* Apply changes from PathOfBuildingCommunity/PathOfBuilding-PoE2#2280 * Fix merge --------- Co-authored-by: LocalIdentity <LocalIdentity@users.noreply.github.com> Co-authored-by: LocalIdentity <localidentity2@gmail.com>
1 parent 610a0a5 commit 4f97c04

2 files changed

Lines changed: 22 additions & 0 deletions

File tree

spec/System/TestItemMods_spec.lua

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -612,4 +612,19 @@ describe("TetsItemMods", function()
612612
assert.are.equals(baseFrenzyChargesMax + 1, build.calcsTab.calcsOutput.FrenzyChargesMax)
613613
assert.are.equals(baseEnduranceChargesMax + 1, build.calcsTab.calcsOutput.EnduranceChargesMax)
614614
end)
615+
616+
it("shows a fallback tooltip when an item's base is no longer supported", function()
617+
local item = new("Item", [[
618+
Rarity: Unique
619+
Legacy Item
620+
Removed Base
621+
]])
622+
local tooltip = new("Tooltip")
623+
624+
assert.has_no.errors(function()
625+
build.itemsTab:AddItemTooltip(tooltip, item)
626+
end)
627+
assert.is_truthy(tooltip.lines[#tooltip.lines].text:find("Item base is not supported", 1, true))
628+
end)
629+
615630
end)

src/Classes/ItemsTab.lua

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3954,6 +3954,13 @@ function ItemsTabClass:AddItemTooltip(tooltip, item, slot, dbMode, maxWidth)
39543954
tooltip.foilType = item.foilType
39553955
tooltip.center = true
39563956
tooltip.color = rarityCode
3957+
-- Shared items can use old base names that no longer exist. Add a tooltip so they can be copied or removed without causing a crash.
3958+
if not item.base or not item.baseName then
3959+
tooltip:AddLine(fontSizeTitle, rarityCode..(item.title or item.name or "Unknown Item"), "FONTIN SC")
3960+
tooltip:AddSeparator(30)
3961+
tooltip:AddLine(fontSizeTitle, colorCodes.NEGATIVE.."Item base is not supported by the current version.", "FONTIN SC")
3962+
return
3963+
end
39573964
self:SetTooltipHeaderInfluence(tooltip, item)
39583965
-- Item name
39593966
if item.title then

0 commit comments

Comments
 (0)