summaryrefslogtreecommitdiff
path: root/src/newgrf_gui.cpp
diff options
context:
space:
mode:
authorglx22 <glx@openttd.org>2021-05-15 23:12:25 +0200
committerLoïc Guilloux <glx22@users.noreply.github.com>2021-05-29 21:08:25 +0200
commit994bf19aef3dde6c9482434bdc51688f76a937ea (patch)
tree9b45b82d460cb00733144ba0dd64ebc6fde478c2 /src/newgrf_gui.cpp
parentef991b1772f5f8b4874f76ea715a9a95811ad979 (diff)
downloadopenttd-994bf19aef3dde6c9482434bdc51688f76a937ea.tar.xz
Fix f6d5c01: Delay deletion when closing windows
Diffstat (limited to 'src/newgrf_gui.cpp')
-rw-r--r--src/newgrf_gui.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/newgrf_gui.cpp b/src/newgrf_gui.cpp
index 9e86a575f..a9b43ea9d 100644
--- a/src/newgrf_gui.cpp
+++ b/src/newgrf_gui.cpp
@@ -424,7 +424,7 @@ struct NewGRFParametersWindow : public Window {
break;
case WID_NP_ACCEPT:
- delete this;
+ this->Close();
break;
}
}
@@ -662,7 +662,7 @@ struct NewGRFWindow : public Window, NewGRFScanCallback {
this->OnInvalidateData(GOID_NEWGRF_CURRENT_LOADED);
}
- ~NewGRFWindow()
+ void Close() override
{
DeleteWindowByClass(WC_GRF_PARAMETERS);
DeleteWindowByClass(WC_TEXTFILE);
@@ -674,6 +674,11 @@ struct NewGRFWindow : public Window, NewGRFScanCallback {
ReloadNewGRFData();
}
+ this->Window::Close();
+ }
+
+ ~NewGRFWindow()
+ {
/* Remove the temporary copy of grf-list used in window */
ClearGRFConfigList(&this->actives);
}
@@ -2121,13 +2126,13 @@ struct SavePresetWindow : public Window {
}
case WID_SVP_CANCEL:
- delete this;
+ this->Close();
break;
case WID_SVP_SAVE: {
Window *w = FindWindowById(WC_GAME_OPTIONS, WN_GAME_OPTIONS_NEWGRF_STATE);
if (w != nullptr && !StrEmpty(this->presetname_editbox.text.buf)) w->OnQueryTextFinished(this->presetname_editbox.text.buf);
- delete this;
+ this->Close();
break;
}
}