diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/glk/window_pair.cpp | 5 | ||||
-rw-r--r-- | engines/glk/window_pair.h | 5 | ||||
-rw-r--r-- | engines/glk/windows.cpp | 10 |
3 files changed, 19 insertions, 1 deletions
diff --git a/engines/glk/window_pair.cpp b/engines/glk/window_pair.cpp index a0fdbb440b..41b4e20a10 100644 --- a/engines/glk/window_pair.cpp +++ b/engines/glk/window_pair.cpp @@ -38,6 +38,11 @@ PairWindow::PairWindow(Windows *windows, glui32 method, Window *key, glui32 size _type = wintype_Pair; } +PairWindow::~PairWindow() { + delete _child1; + delete _child2; +} + void PairWindow::rearrange(const Rect &box) { Rect box1, box2; int min, diff, split, splitwid, max; diff --git a/engines/glk/window_pair.h b/engines/glk/window_pair.h index f77ae9243b..dabae775cf 100644 --- a/engines/glk/window_pair.h +++ b/engines/glk/window_pair.h @@ -49,6 +49,11 @@ public: PairWindow(Windows *windows, glui32 method, Window *key, glui32 size); /** + * Destructor + */ + ~PairWindow(); + + /** * Rearranges the window */ virtual void rearrange(const Rect &box) override; diff --git a/engines/glk/windows.cpp b/engines/glk/windows.cpp index ce1929fedf..4db231c530 100644 --- a/engines/glk/windows.cpp +++ b/engines/glk/windows.cpp @@ -509,12 +509,20 @@ Window::~Window() { if (g_vm->gli_unregister_obj) (*g_vm->gli_unregister_obj)(this, gidisp_Class_Window, _dispRock); - + // Remove the window from any parent + PairWindow *parent = dynamic_cast<PairWindow *>(_parent); + if (parent && parent->_child1 == this) + parent->_child1 = nullptr; + if (parent && parent->_child2 == this) + parent->_child2 = nullptr; + + // Delete any attached window stream _echoStream = nullptr; delete _stream; delete[] _lineTerminatorsBase; + // Remove the window from the master list of windows Window *prev = _prev; Window *next = _next; |