diff options
author | glx22 <glx@openttd.org> | 2021-05-15 23:12:25 +0200 |
---|---|---|
committer | Loïc Guilloux <glx22@users.noreply.github.com> | 2021-05-29 21:08:25 +0200 |
commit | 994bf19aef3dde6c9482434bdc51688f76a937ea (patch) | |
tree | 9b45b82d460cb00733144ba0dd64ebc6fde478c2 /src/highscore_gui.cpp | |
parent | ef991b1772f5f8b4874f76ea715a9a95811ad979 (diff) | |
download | openttd-994bf19aef3dde6c9482434bdc51688f76a937ea.tar.xz |
Fix f6d5c01: Delay deletion when closing windows
Diffstat (limited to 'src/highscore_gui.cpp')
-rw-r--r-- | src/highscore_gui.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/highscore_gui.cpp b/src/highscore_gui.cpp index 356235fa0..e36935c1e 100644 --- a/src/highscore_gui.cpp +++ b/src/highscore_gui.cpp @@ -64,7 +64,7 @@ struct EndGameHighScoreBaseWindow : Window { void OnClick(Point pt, int widget, int click_count) override { - delete this; + this->Close(); } EventState OnKeyPress(WChar key, uint16 keycode) override @@ -79,7 +79,7 @@ struct EndGameHighScoreBaseWindow : Window { case WKC_RETURN: case WKC_ESC: case WKC_SPACE: - delete this; + this->Close(); return ES_HANDLED; default: @@ -122,10 +122,11 @@ struct EndGameWindow : EndGameHighScoreBaseWindow { MarkWholeScreenDirty(); } - ~EndGameWindow() + void Close() override { if (!_networking) DoCommandP(0, PM_PAUSED_NORMAL, 0, CMD_PAUSE); // unpause ShowHighscoreTable(this->window_number, this->rank); + this->EndGameHighScoreBaseWindow::Close(); } void OnPaint() override @@ -169,11 +170,13 @@ struct HighScoreWindow : EndGameHighScoreBaseWindow { this->rank = ranking; } - ~HighScoreWindow() + void Close() override { if (_game_mode != GM_MENU) ShowVitalWindows(); if (!_networking && !this->game_paused_by_player) DoCommandP(0, PM_PAUSED_NORMAL, 0, CMD_PAUSE); // unpause + + this->EndGameHighScoreBaseWindow::Close(); } void OnPaint() override |