Change window close/deallocation to match upstream
This commit is contained in:
@@ -314,9 +314,10 @@ struct NetworkChatWindow : public Window {
|
||||
PositionNetworkChatWindow(this);
|
||||
}
|
||||
|
||||
~NetworkChatWindow()
|
||||
void Close() override
|
||||
{
|
||||
InvalidateWindowData(WC_NEWS_WINDOW, 0, 0);
|
||||
this->Window::Close();
|
||||
}
|
||||
|
||||
void FindWindowPlacementAndResize(int def_width, int def_height) override
|
||||
@@ -470,7 +471,7 @@ struct NetworkChatWindow : public Window {
|
||||
FALLTHROUGH;
|
||||
|
||||
case WID_NC_CLOSE: /* Cancel */
|
||||
delete this;
|
||||
this->Close();
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -497,7 +498,7 @@ struct NetworkChatWindow : public Window {
|
||||
*/
|
||||
void OnInvalidateData(int data = 0, bool gui_scope = true) override
|
||||
{
|
||||
if (data == this->dest) delete this;
|
||||
if (data == this->dest) this->Close();
|
||||
}
|
||||
};
|
||||
|
||||
|
@@ -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::UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
|
||||
@@ -200,8 +201,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) {
|
||||
@@ -282,6 +282,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
|
||||
@@ -289,7 +291,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. */
|
||||
@@ -572,10 +574,10 @@ public:
|
||||
this->InvalidateData();
|
||||
}
|
||||
|
||||
/** Free everything we allocated */
|
||||
~NetworkContentListWindow()
|
||||
void Close() override
|
||||
{
|
||||
_network_content_client.RemoveCallback(this);
|
||||
this->Window::Close();
|
||||
}
|
||||
|
||||
void OnInit() override
|
||||
@@ -852,7 +854,7 @@ public:
|
||||
break;
|
||||
|
||||
case WID_NCL_CANCEL:
|
||||
delete this;
|
||||
this->Close();
|
||||
break;
|
||||
|
||||
case WID_NCL_OPEN_URL:
|
||||
@@ -955,7 +957,7 @@ public:
|
||||
{
|
||||
if (!success) {
|
||||
ShowErrorMessage(STR_CONTENT_ERROR_COULD_NOT_CONNECT, INVALID_STRING_ID, WL_ERROR);
|
||||
delete this;
|
||||
this->Close();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@@ -32,11 +32,7 @@ public:
|
||||
*/
|
||||
BaseNetworkContentDownloadStatusWindow(WindowDesc *desc);
|
||||
|
||||
/**
|
||||
* Free everything associated with this window.
|
||||
*/
|
||||
~BaseNetworkContentDownloadStatusWindow();
|
||||
|
||||
void Close() override;
|
||||
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override;
|
||||
void DrawWidget(const Rect &r, int widget) const override;
|
||||
void OnDownloadProgress(const ContentInfo *ci, int bytes) override;
|
||||
|
@@ -523,9 +523,10 @@ public:
|
||||
this->servers.ForceRebuild();
|
||||
}
|
||||
|
||||
~NetworkGameWindow()
|
||||
void Close() override
|
||||
{
|
||||
this->last_sorting = this->servers.GetListing();
|
||||
this->Window::Close();
|
||||
}
|
||||
|
||||
void OnInit() override
|
||||
@@ -2378,7 +2379,7 @@ struct NetworkCompanyPasswordWindow : public Window {
|
||||
FALLTHROUGH;
|
||||
|
||||
case WID_NCP_CANCEL:
|
||||
delete this;
|
||||
this->Close();
|
||||
break;
|
||||
|
||||
case WID_NCP_SAVE_AS_DEFAULT_PASSWORD:
|
||||
@@ -2485,18 +2486,18 @@ struct NetworkAskRelayWindow : public Window {
|
||||
switch (widget) {
|
||||
case WID_NAR_NO:
|
||||
_network_coordinator_client.ConnectFailure(this->token, 0);
|
||||
delete this;
|
||||
this->Close();
|
||||
break;
|
||||
|
||||
case WID_NAR_YES_ONCE:
|
||||
_network_coordinator_client.StartTurnConnection(this->token);
|
||||
delete this;
|
||||
this->Close();
|
||||
break;
|
||||
|
||||
case WID_NAR_YES_ALWAYS:
|
||||
_settings_client.network.use_relay_service = URS_ALLOW;
|
||||
_network_coordinator_client.StartTurnConnection(this->token);
|
||||
delete this;
|
||||
this->Close();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user