[Scummvm-cvs-logs] scummvm master -> dd9ab7accbe7671134d6c9303d94f527ef599404

wjp wjp at usecode.org
Thu Sep 5 20:25:05 CEST 2013


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:
dd9ab7accb WINTERMUTE: Don't clean up _scripts mid-iteration


Commit: dd9ab7accbe7671134d6c9303d94f527ef599404
    https://github.com/scummvm/scummvm/commit/dd9ab7accbe7671134d6c9303d94f527ef599404
Author: Willem Jan Palenstijn (wjp at usecode.org)
Date: 2013-09-05T11:23:42-07:00

Commit Message:
WINTERMUTE: Don't clean up _scripts mid-iteration

Scripts executing from ScEngine::tick() can call
ScEngine::unbreakableTick() via scCallMethod("SaveGame") and
applyEvent("BeforeSave").

This recursive execution could cause finished scripts being removed
from _scripts while ScEngine::tick() is still iterating over that array.

Changed paths:
    engines/wintermute/base/scriptables/script_engine.cpp



diff --git a/engines/wintermute/base/scriptables/script_engine.cpp b/engines/wintermute/base/scriptables/script_engine.cpp
index dd24457..bb819b2 100644
--- a/engines/wintermute/base/scriptables/script_engine.cpp
+++ b/engines/wintermute/base/scriptables/script_engine.cpp
@@ -362,6 +362,8 @@ bool ScEngine::tick() {
 
 //////////////////////////////////////////////////////////////////////////
 bool ScEngine::tickUnbreakable() {
+	ScScript *oldScript = _currentScript;
+
 	// execute unbreakable scripts
 	for (uint32 i = 0; i < _scripts.size(); i++) {
 		if (!_scripts[i]->_unbreakable) {
@@ -373,9 +375,12 @@ bool ScEngine::tickUnbreakable() {
 			_scripts[i]->executeInstruction();
 		}
 		_scripts[i]->finish();
-		_currentScript = nullptr;
+		_currentScript = oldScript;
 	}
-	removeFinishedScripts();
+
+	// NB: Don't remove finished scripts here since we could be recursively
+	// executing scripts. Doing so could invalidate the outer iteration in
+	// ::tick() over _scripts.
 
 	return STATUS_OK;
 }






More information about the Scummvm-git-logs mailing list