Fix memory read error by moving destruction of dialog to onUpdate

This commit is contained in:
Benau 2019-06-12 12:07:58 +08:00
parent effc0a27dc
commit 392d3cfe86
2 changed files with 6 additions and 3 deletions

View File

@ -51,6 +51,7 @@ ServerInfoDialog::ServerInfoDialog(std::shared_ptr<Server> server)
Log::info("ServerInfoDialog", "Server id is %d, owner is %d",
server->getServerId(), server->getServerOwner());
m_self_destroy = false;
m_join_server = false;
loadFromFile("online/server_info_dialog.stkgui");
getWidget<LabelWidget>("title")->setText(server->getName(), true);
@ -202,7 +203,7 @@ GUIEngine::EventPropagation
}
else if(selection == m_join_widget->m_properties[PROP_ID])
{
requestJoin();
m_join_server = true;
return GUIEngine::EVENT_BLOCK;
}
}
@ -219,7 +220,7 @@ void ServerInfoDialog::onEnterPressedInternal()
const int playerID = PLAYER_ID_GAME_MASTER;
if (GUIEngine::isFocusedForPlayer(m_options_widget, playerID))
return;
requestJoin();
m_join_server = true;
} // onEnterPressedInternal
// -----------------------------------------------------------------------------
@ -245,4 +246,6 @@ void ServerInfoDialog::onUpdate(float dt)
ModalDialog::dismiss();
return;
}
if (m_join_server)
requestJoin();
} // onUpdate

View File

@ -42,7 +42,7 @@ class ServerInfoDialog : public GUIEngine::ModalDialog
{
private:
bool m_self_destroy;
bool m_self_destroy, m_join_server;
const std::shared_ptr<Server> m_server;