[Scummvm-git-logs] scummvm master -> 741620e4bc3c11b9bbe567ac4ef789975a6efe0e

dreammaster noreply at scummvm.org
Sun Mar 24 20:50:07 UTC 2024


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:
741620e4bc ENGINES: Allow shouldQuit to return true immediately


Commit: 741620e4bc3c11b9bbe567ac4ef789975a6efe0e
    https://github.com/scummvm/scummvm/commit/741620e4bc3c11b9bbe567ac4ef789975a6efe0e
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2024-03-24T13:49:59-07:00

Commit Message:
ENGINES: Allow shouldQuit to return true immediately

It's been a long time problem that calling quitGame
doesn't result in shouldQuit returning true until
after event processing has been done. This has resulted
in engines doing various hacks such as manually doing
an event loop, or maintaining their own quit flag.

This helps resolve the problem by additionally adding
a _quitRequested flag that's set when quitGame is called,
and additionally checking for it in shouldQuit()

Changed paths:
    engines/engine.cpp
    engines/engine.h


diff --git a/engines/engine.cpp b/engines/engine.cpp
index 2faf7097dee..d6a7a93fe34 100644
--- a/engines/engine.cpp
+++ b/engines/engine.cpp
@@ -63,6 +63,7 @@
 
 // FIXME: HACK for error()
 Engine *g_engine = 0;
+bool Engine::_quitRequested;
 
 // Output formatter for debug() and error() which invokes
 // the errorString method of the active engine, if any.
@@ -152,6 +153,7 @@ Engine::Engine(OSystem *syst)
 		_lastAutosaveTime(_system->getMillis()) {
 
 	g_engine = this;
+	_quitRequested = false;
 	Common::setErrorOutputFormatter(defaultOutputFormatter);
 	Common::setErrorHandler(defaultErrorHandler);
 
@@ -972,11 +974,13 @@ void Engine::quitGame() {
 
 	event.type = Common::EVENT_QUIT;
 	g_system->getEventManager()->pushEvent(event);
+	_quitRequested = true;
 }
 
 bool Engine::shouldQuit() {
 	Common::EventManager *eventMan = g_system->getEventManager();
-	return (eventMan->shouldQuit() || eventMan->shouldReturnToLauncher());
+	return eventMan->shouldQuit() || eventMan->shouldReturnToLauncher()
+		|| _quitRequested;
 }
 
 GUI::Debugger *Engine::getOrCreateDebugger() {
diff --git a/engines/engine.h b/engines/engine.h
index ade46d5fd9b..0b176bee852 100644
--- a/engines/engine.h
+++ b/engines/engine.h
@@ -233,9 +233,13 @@ private:
 	 * Optional debugger for the engine.
 	 */
 	GUI::Debugger *_debugger;
-public:
 
+	/**
+	 * Flag for whether the quitGame method has been called
+	 */
+	static bool _quitRequested;
 
+public:
 	/**
 	 * Engine features.
 	 *




More information about the Scummvm-git-logs mailing list