mirror of
https://gitea.wildfiregames.com/0ad/0ad
synced 2026-08-15 14:43:32 -07:00
Since #7786, the GUI tick completed normally after calling `closePageCallback` instead of being cancelled like previously. Since `Engine.EndGame` deletes the internal `g_Game` pointer, every Engine call after it that tried to access `g_Game` caused a segfault. This patch solves it by moving `Engine.EndGame` to the very end, right before closing the session page. In order to follow the convention that only functions directly closing the page are called `closePageCallback`, that function is in turn renamed to `closeSession`. Additionally, this allows only resolving the promise with a bool (`showSummary`) and then only calling `getNextPageOpenRequest` at the end of `init` for reasons of simplicity.
34 lines
855 B
JavaScript
34 lines
855 B
JavaScript
/**
|
|
* This is the same as a regular MessageBox, but it pauses if it is
|
|
* a single-player game, until the player answered the dialog.
|
|
*/
|
|
class SessionMessageBox
|
|
{
|
|
async display(closeSession)
|
|
{
|
|
closeOpenDialogs();
|
|
g_PauseControl.implicitPause();
|
|
|
|
const buttonId = await Engine.OpenChildPage(
|
|
"page_msgbox.xml",
|
|
{
|
|
"width": this.Width,
|
|
"height": this.Height,
|
|
"title": this.Title,
|
|
"message": this.Caption,
|
|
"buttonCaptions": this.Buttons ? this.Buttons.map(button => button.caption) : undefined,
|
|
});
|
|
|
|
this.closeSession = closeSession;
|
|
if (this.Buttons && this.Buttons[buttonId].onPress)
|
|
this.Buttons[buttonId].onPress.call(this);
|
|
|
|
if (this.ResumeOnClose)
|
|
resumeGame();
|
|
}
|
|
}
|
|
|
|
SessionMessageBox.prototype.Width = 400;
|
|
SessionMessageBox.prototype.Height = 200;
|
|
|
|
SessionMessageBox.prototype.ResumeOnClose = true;
|