diff options
author | glx22 <glx22@users.noreply.github.com> | 2019-01-31 23:15:22 +0100 |
---|---|---|
committer | Charles Pigott <charlespigott@googlemail.com> | 2019-01-31 22:15:22 +0000 |
commit | bb9b8eb464a096e7bcffd4bcb67411d04b21aa0e (patch) | |
tree | 883367fa8b12499c96c950fcd6cbac12e88c716b /src | |
parent | 8e02b7952b3fa3e9caff3cc78abbe68ce0b5a63d (diff) | |
download | openttd-bb9b8eb464a096e7bcffd4bcb67411d04b21aa0e.tar.xz |
Fix #7089: Close NewGRF textfile windows when their data is invalid (#7106)
Diffstat (limited to 'src')
-rw-r--r-- | src/newgrf_gui.cpp | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/src/newgrf_gui.cpp b/src/newgrf_gui.cpp index 868fad968..5f32b5bad 100644 --- a/src/newgrf_gui.cpp +++ b/src/newgrf_gui.cpp @@ -725,7 +725,11 @@ struct NewGRFWindow : public Window, NewGRFScanCallback { GRFConfig *d = new GRFConfig(*a); d->next = (*c)->next; d->CopyParams(**c); - if (this->active_sel == *c) this->active_sel = NULL; + if (this->active_sel == *c) { + DeleteWindowByClass(WC_GRF_PARAMETERS); + DeleteWindowByClass(WC_TEXTFILE); + this->active_sel = NULL; + } delete *c; *c = d; iter->second = d; @@ -1022,7 +1026,10 @@ struct NewGRFWindow : public Window, NewGRFScanCallback { GRFConfig *c; for (c = this->actives; c != NULL && i > 0; c = c->next, i--) {} - if (this->active_sel != c) DeleteWindowByClass(WC_GRF_PARAMETERS); + if (this->active_sel != c) { + DeleteWindowByClass(WC_GRF_PARAMETERS); + DeleteWindowByClass(WC_TEXTFILE); + } this->active_sel = c; this->avail_sel = NULL; this->avail_pos = -1; @@ -1039,6 +1046,7 @@ struct NewGRFWindow : public Window, NewGRFScanCallback { case WID_NS_REMOVE: { // Remove GRF if (this->active_sel == NULL || !this->editable) break; DeleteWindowByClass(WC_GRF_PARAMETERS); + DeleteWindowByClass(WC_TEXTFILE); /* Choose the next GRF file to be the selected file. */ GRFConfig *newsel = this->active_sel->next; @@ -1080,6 +1088,7 @@ struct NewGRFWindow : public Window, NewGRFScanCallback { this->active_sel = NULL; DeleteWindowByClass(WC_GRF_PARAMETERS); if (i < this->avails.Length()) { + if (this->avail_sel != this->avails[i]) DeleteWindowByClass(WC_TEXTFILE); this->avail_sel = this->avails[i]; this->avail_pos = i; } @@ -1152,11 +1161,11 @@ struct NewGRFWindow : public Window, NewGRFScanCallback { virtual void OnNewGRFsScanned() { + if (this->active_sel == NULL) DeleteWindowByClass(WC_TEXTFILE); this->avail_sel = NULL; this->avail_pos = -1; this->avails.ForceRebuild(); this->DeleteChildWindows(WC_QUERY_STRING); // Remove the parameter query window - this->DeleteChildWindows(WC_TEXTFILE); // Remove the view textfile window } virtual void OnDropdownSelect(int widget, int index) @@ -1173,6 +1182,7 @@ struct NewGRFWindow : public Window, NewGRFScanCallback { ResetObjectToPlace(); DeleteWindowByClass(WC_GRF_PARAMETERS); + DeleteWindowByClass(WC_TEXTFILE); this->active_sel = NULL; this->InvalidateData(GOID_NEWGRF_PRESET_LOADED); } @@ -1221,7 +1231,7 @@ struct NewGRFWindow : public Window, NewGRFScanCallback { *l = new GRFConfig(*f); (*l)->next = c->next; - if (active_sel == c) active_sel = *l; + if (this->active_sel == c) this->active_sel = *l; delete c; } @@ -1347,6 +1357,9 @@ struct NewGRFWindow : public Window, NewGRFScanCallback { if (this->avails.Length() == 0) this->avail_pos = -1; if (this->avail_pos >= 0) { + this->active_sel = NULL; + DeleteWindowByClass(WC_GRF_PARAMETERS); + if (this->avail_sel != this->avails[this->avail_pos]) DeleteWindowByClass(WC_TEXTFILE); this->avail_sel = this->avails[this->avail_pos]; this->vscroll2->ScrollTowards(this->avail_pos); this->InvalidateData(0); @@ -1509,6 +1522,8 @@ private: { if (this->avail_sel == NULL || !this->editable || HasBit(this->avail_sel->flags, GCF_INVALID)) return false; + DeleteWindowByClass(WC_TEXTFILE); + uint count = 0; GRFConfig **entry = NULL; GRFConfig **list; @@ -1968,6 +1983,7 @@ static void NewGRFConfirmationCallback(Window *w, bool confirmed) { if (confirmed) { DeleteWindowByClass(WC_GRF_PARAMETERS); + DeleteWindowByClass(WC_TEXTFILE); NewGRFWindow *nw = dynamic_cast<NewGRFWindow*>(w); GamelogStartAction(GLAT_GRF); |