fix: static lastSpellCount shared across SpellHandler instances
Some checks are pending
Build / Build (arm64) (push) Waiting to run
Build / Build (x86-64) (push) Waiting to run
Build / Build (macOS arm64) (push) Waiting to run
Build / Build (windows-arm64) (push) Waiting to run
Build / Build (windows-x86-64) (push) Waiting to run
Security / CodeQL (C/C++) (push) Waiting to run
Security / Semgrep (push) Waiting to run
Security / Sanitizer Build (ASan/UBSan) (push) Waiting to run

The spellbook tab dirty check used a function-local static, meaning
switching to a character with the same spell count would skip the
rebuild and return the previous character's tabs. Changed to an
instance member so each SpellHandler tracks its own count.
This commit is contained in:
Kelsi 2026-03-29 19:08:58 -07:00
parent e629898bfb
commit bf63d8e385
2 changed files with 6 additions and 3 deletions

View file

@ -307,6 +307,7 @@ private:
// Spell book tabs // Spell book tabs
std::vector<SpellBookTab> spellBookTabs_; std::vector<SpellBookTab> spellBookTabs_;
size_t lastSpellCount_ = 0;
bool spellBookTabsDirty_ = true; bool spellBookTabsDirty_ = true;
// Talent wipe confirm dialog // Talent wipe confirm dialog

View file

@ -547,10 +547,12 @@ void SpellHandler::useItemById(uint32_t itemId) {
} }
const std::vector<SpellHandler::SpellBookTab>& SpellHandler::getSpellBookTabs() { const std::vector<SpellHandler::SpellBookTab>& SpellHandler::getSpellBookTabs() {
static size_t lastSpellCount = 0; // Must be an instance member, not static — a static is shared across all
if (lastSpellCount == knownSpells_.size() && !spellBookTabsDirty_) // SpellHandler instances, so switching characters with the same spell count
// would skip the rebuild and return the previous character's tabs.
if (lastSpellCount_ == knownSpells_.size() && !spellBookTabsDirty_)
return spellBookTabs_; return spellBookTabs_;
lastSpellCount = knownSpells_.size(); lastSpellCount_ = knownSpells_.size();
spellBookTabsDirty_ = false; spellBookTabsDirty_ = false;
spellBookTabs_.clear(); spellBookTabs_.clear();