Skip to content

Guard Trader result dropdown tooltip against stale state#9742

Open
mcagnion wants to merge 3 commits intoPathOfBuildingCommunity:devfrom
mcagnion:bugfix/trade-query-tooltip-nil
Open

Guard Trader result dropdown tooltip against stale state#9742
mcagnion wants to merge 3 commits intoPathOfBuildingCommunity:devfrom
mcagnion:bugfix/trade-query-tooltip-nil

Conversation

@mcagnion
Copy link
Copy Markdown
Contributor

@mcagnion mcagnion commented Apr 9, 2026

Description of the problem being solved:

The Trader result dropdown tooltip can be evaluated after the sorted row state or backing result entry has changed, which can leave the callback pointing at missing entries and trigger nil accesses.

Description of the solution:

Add early-return guards in the resultDropdown tooltip callback when:

  • the sorted row is missing
  • the requested dropdown entry is missing
  • the backing result entry is no longer available

This keeps the nominal path unchanged and only hardens the callback against transient state desynchronization.

Steps taken to verify a working solution:

  • Added targeted tests in TestTradeQuery_spec.lua covering:
    • a missing sortedResultTbl[row_idx] row
    • a missing backing result entry for the selected dropdown item
  • Ran both targeted tooltip guard tests successfully.

Notes:

The nil guard lost during the vaisest/trader-improvements merge
caused a crash when hovering the result dropdown after clearing
search results.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@mcagnion mcagnion force-pushed the bugfix/trade-query-tooltip-nil branch 3 times, most recently from f853db1 to 8344d05 Compare April 9, 2026 17:32
@mcagnion mcagnion force-pushed the bugfix/trade-query-tooltip-nil branch from 8344d05 to 48859b1 Compare April 9, 2026 17:59
@Nightblade
Copy link
Copy Markdown
Contributor

Hi, please remember to use TAB indentation. ( spec/System/TestTradeQuery_spec.lua is spaced. )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants