summaryrefslogtreecommitdiff
path: root/src/network/network_content_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/network/network_content_gui.cpp
parentef991b1772f5f8b4874f76ea715a9a95811ad979 (diff)
downloadopenttd-994bf19aef3dde6c9482434bdc51688f76a937ea.tar.xz
Fix f6d5c01: Delay deletion when closing windows
Diffstat (limited to 'src/network/network_content_gui.cpp')
-rw-r--r--src/network/network_content_gui.cpp18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/network/network_content_gui.cpp b/src/network/network_content_gui.cpp
index dd9590e99..8c75cb572 100644
--- a/src/network/network_content_gui.cpp
+++ b/src/network/network_content_gui.cpp
@@ -109,9 +109,10 @@ BaseNetworkContentDownloadStatusWindow::BaseNetworkContentDownloadStatusWindow(W
this->InitNested(WN_NETWORK_STATUS_WINDOW_CONTENT_DOWNLOAD);
}
-BaseNetworkContentDownloadStatusWindow::~BaseNetworkContentDownloadStatusWindow()
+void BaseNetworkContentDownloadStatusWindow::Close()
{
_network_content_client.RemoveCallback(this);
+ this->Window::Close();
}
void BaseNetworkContentDownloadStatusWindow::DrawWidget(const Rect &r, int widget) const
@@ -171,8 +172,7 @@ public:
this->parent = FindWindowById(WC_NETWORK_WINDOW, WN_NETWORK_WINDOW_CONTENT_LIST);
}
- /** Free whatever we've allocated */
- ~NetworkContentDownloadStatusWindow()
+ void Close() override
{
TarScanner::Mode mode = TarScanner::NONE;
for (auto ctype : this->receivedTypes) {
@@ -254,6 +254,8 @@ public:
/* Always invalidate the download window; tell it we are going to be gone */
InvalidateWindowData(WC_NETWORK_WINDOW, WN_NETWORK_WINDOW_CONTENT_LIST, 2);
+
+ this->BaseNetworkContentDownloadStatusWindow::Close();
}
void OnClick(Point pt, int widget, int click_count) override
@@ -261,7 +263,7 @@ public:
if (widget == WID_NCDS_CANCELOK) {
if (this->downloaded_bytes != this->total_bytes) {
_network_content_client.CloseConnection();
- delete this;
+ this->Close();
} else {
/* If downloading succeeded, close the online content window. This will close
* the current window as well. */
@@ -549,10 +551,10 @@ public:
this->InvalidateData();
}
- /** Free everything we allocated */
- ~NetworkContentListWindow()
+ void Close() override
{
_network_content_client.RemoveCallback(this);
+ this->Window::Close();
}
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
@@ -837,7 +839,7 @@ public:
break;
case WID_NCL_CANCEL:
- delete this;
+ this->Close();
break;
case WID_NCL_OPEN_URL:
@@ -941,7 +943,7 @@ public:
{
if (!success) {
ShowErrorMessage(STR_CONTENT_ERROR_COULD_NOT_CONNECT, INVALID_STRING_ID, WL_ERROR);
- delete this;
+ this->Close();
return;
}