diff options
author | Paul Gilbert | 2019-05-18 17:13:55 -1000 |
---|---|---|
committer | Paul Gilbert | 2019-05-24 18:21:06 -0700 |
commit | 0d172c8ca695ae67b881b92add19e488c6053fbb (patch) | |
tree | 26b48eb1adde8577224e61e3d1a3a23a9edcebf9 /engines/glk | |
parent | e3454b5d96c258f59a1186eae1bdfd01d5f7af3e (diff) | |
download | scummvm-rg350-0d172c8ca695ae67b881b92add19e488c6053fbb.tar.gz scummvm-rg350-0d172c8ca695ae67b881b92add19e488c6053fbb.tar.bz2 scummvm-rg350-0d172c8ca695ae67b881b92add19e488c6053fbb.zip |
GLK: Fix freeing closed windows
Diffstat (limited to 'engines/glk')
-rw-r--r-- | engines/glk/windows.cpp | 22 | ||||
-rw-r--r-- | engines/glk/windows.h | 5 |
2 files changed, 24 insertions, 3 deletions
diff --git a/engines/glk/windows.cpp b/engines/glk/windows.cpp index ffb1fbf906..7b6833ff59 100644 --- a/engines/glk/windows.cpp +++ b/engines/glk/windows.cpp @@ -187,10 +187,21 @@ void Windows::windowClose(Window *win, StreamResult *result) { return; } + // Detach window being closed from parent pair window + pairWin->_children.remove_at(index); + win->_parent = nullptr; + if (!(pairWin->_dir & winmethod_Arbitrary)) { - sibWin = (index = ((int)pairWin->_children.size() - 1)) ? - pairWin->_children.front() : pairWin->_children[index + 1]; + // Get the remaining child window + assert(pairWin->_children.size() == 1); + sibWin = pairWin->_children.front(); + + // Detach it from the pair window + index = pairWin->_children.indexOf(sibWin); + assert(index >= 0); + pairWin->_children.remove_at(index); + // Set up window as either the singular root, or grandparent pair window if one exists grandparWin = dynamic_cast<PairWindow *>(pairWin->_parent); if (!grandparWin) { _rootWin = sibWin; @@ -453,7 +464,12 @@ uint Windows::rgbShift(uint color) { /*--------------------------------------------------------------------------*/ Windows::iterator &Windows::iterator::operator++() { - _current = _windows->iterateTreeOrder(_current); + _current = _current->_next; + return *this; +} + +Windows::iterator &Windows::iterator::operator--() { + _current = _current->_prev; return *this; } diff --git a/engines/glk/windows.h b/engines/glk/windows.h index 9cab07acf9..1974b3e4a4 100644 --- a/engines/glk/windows.h +++ b/engines/glk/windows.h @@ -74,6 +74,11 @@ public: iterator &operator++(); /** + * Move to previous + */ + iterator &operator--(); + + /** * Equality test */ bool operator==(const iterator &i) { |