From 994bf19aef3dde6c9482434bdc51688f76a937ea Mon Sep 17 00:00:00 2001 From: glx22 Date: Sat, 15 May 2021 23:12:25 +0200 Subject: Fix f6d5c01: Delay deletion when closing windows --- src/ai/ai_gui.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'src/ai/ai_gui.cpp') diff --git a/src/ai/ai_gui.cpp b/src/ai/ai_gui.cpp index 49e37621e..1817148f4 100644 --- a/src/ai/ai_gui.cpp +++ b/src/ai/ai_gui.cpp @@ -196,7 +196,7 @@ struct AIListWindow : public Window { this->SetDirty(); if (click_count > 1) { this->ChangeAI(); - delete this; + this->Close(); } } break; @@ -204,12 +204,12 @@ struct AIListWindow : public Window { case WID_AIL_ACCEPT: { this->ChangeAI(); - delete this; + this->Close(); break; } case WID_AIL_CANCEL: - delete this; + this->Close(); break; } } @@ -227,7 +227,7 @@ struct AIListWindow : public Window { void OnInvalidateData(int data = 0, bool gui_scope = true) override { if (_game_mode == GM_NORMAL && Company::IsValidID(this->slot)) { - delete this; + this->Close(); return; } @@ -518,7 +518,7 @@ struct AISettingsWindow : public Window { } case WID_AIS_ACCEPT: - delete this; + this->Close(); break; case WID_AIS_RESET: @@ -655,7 +655,7 @@ struct ScriptTextfileWindow : public TextfileWindow { { const char *textfile = GetConfig(slot)->GetTextfile(file_type, slot); if (textfile == nullptr) { - delete this; + this->Close(); } else { this->LoadTextfile(textfile, (slot == OWNER_DEITY) ? GAME_DIR : AI_DIR); } @@ -744,10 +744,11 @@ struct AIConfigWindow : public Window { this->OnInvalidateData(0); } - ~AIConfigWindow() + void Close() override { DeleteWindowByClass(WC_AI_LIST); DeleteWindowByClass(WC_AI_SETTINGS); + this->Window::Close(); } void SetStringParameters(int widget) const override @@ -929,7 +930,7 @@ struct AIConfigWindow : public Window { break; case WID_AIC_CLOSE: - delete this; + this->Close(); break; case WID_AIC_CONTENT_DOWNLOAD: -- cgit v1.2.3-54-g00ecf