summaryrefslogtreecommitdiff
path: root/src/window_gui.h
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/window_gui.h
parentef991b1772f5f8b4874f76ea715a9a95811ad979 (diff)
downloadopenttd-994bf19aef3dde6c9482434bdc51688f76a937ea.tar.xz
Fix f6d5c01: Delay deletion when closing windows
Diffstat (limited to 'src/window_gui.h')
-rw-r--r--src/window_gui.h12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/window_gui.h b/src/window_gui.h
index 1195c6c49..c84ad333b 100644
--- a/src/window_gui.h
+++ b/src/window_gui.h
@@ -277,6 +277,9 @@ enum TooltipCloseCondition {
* Data structure for an opened window
*/
struct Window : ZeroedMemoryAllocator {
+private:
+ static std::vector<Window *> closed_windows;
+
protected:
void InitializeData(WindowNumber window_number);
void InitializePositionSize(int x, int y, int min_width, int min_height);
@@ -284,11 +287,12 @@ protected:
std::vector<int> scheduled_invalidation_data; ///< Data of scheduled OnInvalidateData() calls.
+ /* Protected to prevent deletion anywhere outside Window::DeleteClosedWindows(). */
+ virtual ~Window();
+
public:
Window(WindowDesc *desc);
- virtual ~Window();
-
/**
* Helper allocation function to disallow something.
* Don't allow arrays; arrays of Windows are pointless as you need
@@ -506,6 +510,8 @@ public:
static int SortButtonWidth();
void DeleteChildWindows(WindowClass wc = WC_INVALID) const;
+ virtual void Close();
+ static void DeleteClosedWindows();
void SetDirty() const;
void ReInit(int rx = 0, int ry = 0);
@@ -916,7 +922,7 @@ public:
this->parent = parent;
}
- virtual ~PickerWindowBase();
+ void Close() override;
};
Window *BringWindowToFrontById(WindowClass cls, WindowNumber number);