mirror of
https://github.com/brues-code/ClassicAPI.git
synced 2026-11-16 08:00:42 +00:00
The initial fire used FUN_00702690, whose exec-context mutation (DAT_00ceeac0) is only valid from the engine's top-level frame-script dispatch; firing it from inside the item builder (mid-Script_Set*, and in the wild under a stack of addon Set* wrappers) raised through the outer wrappers. Two fixes make the fire safe for normal handlers: - Call the inner invoker FUN_00704d50(handler, tooltip) directly. It binds the global `this` = tooltip and runs the handler under its own protected pcall (0 args), self-contained and context-independent. - Snapshot lua_gettop before the fire and lua_settop back after, so the still- running outer C code sees exactly the stack it left. Without this the invoker left the stack shifted and the outer code / other DLLs' hooks indexed a stale slot -> ACCESS_VIOLATION. Verified in-game: SetScript / HookScript / GetScript all work, `this` is the tooltip (a1 is nil -- vanilla convention, not modern `self`), and no-op / print / AddLine handlers fire cleanly on bag / equipped / merchant / auction. Docs: correct the handler example to use `this` (not a `self` arg), and add the caveat that re-entrant tooltip rebuilds from the handler (ShowCompareItem, Set* on another tooltip) can crash in a hook-heavy client and must be deferred (C_Timer.After(0, ...)) -- the event fires mid-build.