mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-03-23 07:40:14 +00:00
Fix crash in character creation by deferring callback to next update
The charCreateCallback was firing synchronously during ImGui render, causing a state transition before the create screen's ImGui::End() was called. Defer the callback to GameHandler::update() and ensure update() runs during CHARACTER_CREATION and CHARACTER_SELECTION states.
This commit is contained in:
parent
26cd0bc57d
commit
2db690a866
3 changed files with 21 additions and 5 deletions
|
|
@ -406,6 +406,14 @@ bool GameHandler::isConnected() const {
|
|||
}
|
||||
|
||||
void GameHandler::update(float deltaTime) {
|
||||
// Fire deferred char-create callback (outside ImGui render)
|
||||
if (pendingCharCreateResult_) {
|
||||
pendingCharCreateResult_ = false;
|
||||
if (charCreateCallback_) {
|
||||
charCreateCallback_(pendingCharCreateSuccess_, pendingCharCreateMsg_);
|
||||
}
|
||||
}
|
||||
|
||||
if (!socket && !singlePlayerMode_) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -852,9 +860,10 @@ void GameHandler::createCharacter(const CharCreateData& data) {
|
|||
characters.push_back(ch);
|
||||
|
||||
LOG_INFO("Single-player character created: ", ch.name);
|
||||
if (charCreateCallback_) {
|
||||
charCreateCallback_(true, "Character created!");
|
||||
}
|
||||
// Defer callback to next update() so ImGui frame completes first
|
||||
pendingCharCreateResult_ = true;
|
||||
pendingCharCreateSuccess_ = true;
|
||||
pendingCharCreateMsg_ = "Character created!";
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue