[Scummvm-git-logs] scummvm master -> d8f43160df030abd06f3f941d7edd02b6f4c9fba

dreammaster paulfgilbert at gmail.com
Tue Apr 9 04:46:40 CEST 2019


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
d8f43160df GLK: Fixes for properly closing windows


Commit: d8f43160df030abd06f3f941d7edd02b6f4c9fba
    https://github.com/scummvm/scummvm/commit/d8f43160df030abd06f3f941d7edd02b6f4c9fba
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2019-04-08T19:46:28-07:00

Commit Message:
GLK: Fixes for properly closing windows

Changed paths:
    engines/glk/windows.cpp


diff --git a/engines/glk/windows.cpp b/engines/glk/windows.cpp
index 7ffc396..d01f9de 100644
--- a/engines/glk/windows.cpp
+++ b/engines/glk/windows.cpp
@@ -180,23 +180,27 @@ void Windows::windowClose(Window *win, StreamResult *result) {
 		PairWindow *pairWin = dynamic_cast<PairWindow *>(win->_parent);
 		PairWindow *grandparWin;
 
-		int index = pairWin->_children.indexOf(win);
-		if (index == -1) {
-			warning("windowClose: window tree is corrupted");
-			return;
-		}
-
-		sibWin = (index = ((int)pairWin->_children.size() - 1)) ?
-			pairWin->_children.front() : pairWin->_children[index + 1];
+		if (pairWin) {
+			int index = pairWin->_children.indexOf(win);
+			if (index == -1) {
+				warning("windowClose: window tree is corrupted");
+				return;
+			}
 
-		grandparWin = dynamic_cast<PairWindow *>(pairWin->_parent);
-		if (!grandparWin) {
-			_rootWin = sibWin;
-			sibWin->_parent = nullptr;
-		} else {
-			index = grandparWin->_children.indexOf(pairWin);
-			grandparWin->_children[index] = sibWin;
-			sibWin->_parent = grandparWin;
+			if (!(pairWin->_dir & winmethod_Arbitrary)) {
+				sibWin = (index = ((int)pairWin->_children.size() - 1)) ?
+					pairWin->_children.front() : pairWin->_children[index + 1];
+
+				grandparWin = dynamic_cast<PairWindow *>(pairWin->_parent);
+				if (!grandparWin) {
+					_rootWin = sibWin;
+					sibWin->_parent = nullptr;
+				} else {
+					index = grandparWin->_children.indexOf(pairWin);
+					grandparWin->_children[index] = sibWin;
+					sibWin->_parent = grandparWin;
+				}
+			}
 		}
 
 		// Begin closation
@@ -206,12 +210,9 @@ void Windows::windowClose(Window *win, StreamResult *result) {
 		// crawl up the tree to the root window.
 		win->close(true);
 
-		// This probably isn't necessary, but the child *is* gone, so just in case.
-		index = pairWin->_children.indexOf(win);
-		pairWin->_children[index] = nullptr;
-
-		// Now we can delete the parent pair.
-		pairWin->close(false);
+		if (pairWin && !(pairWin->_dir & winmethod_Arbitrary))
+			// Now we can delete the parent pair.
+			pairWin->close(false);
 
 		// Sort out the arrangements
 		rearrange();
@@ -526,18 +527,14 @@ Window::~Window() {
 	if (g_vm->gli_unregister_obj)
 		(*g_vm->gli_unregister_obj)(this, gidisp_Class_Window, _dispRock);
 
-	// Remove the window from any parent
+	// Remove the window from the parent's children list
 	PairWindow *parent = dynamic_cast<PairWindow *>(_parent);
 	if (parent) {
 		int index = parent->_children.indexOf(this);
 		if (index != -1)
-			parent->_children[index] = nullptr;
+			parent->_children.remove_at(index);
 	}
 
-	// Delete any attached window stream
-	_echoStream = nullptr;
-	delete _stream;
-
 	delete[] _lineTerminatorsBase;
 
 	// Remove the window from the master list of windows
@@ -550,6 +547,10 @@ Window::~Window() {
 		_windows->_windowList = next;
 	if (next)
 		next->_prev = prev;
+
+	// Delete any attached window stream
+	_echoStream = nullptr;
+	delete _stream;
 }
 
 void Window::close(bool recurse) {





More information about the Scummvm-git-logs mailing list