[Scummvm-git-logs] scummvm master -> 7abf9ab5fde40b720a43b356f6c46c8de0a468cb

tag2015 noreply at scummvm.org
Fri May 3 10:58:10 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:
7abf9ab5fd AGS: Engine: fixed "mouse up" event could cause a recursive on_event


Commit: 7abf9ab5fde40b720a43b356f6c46c8de0a468cb
    https://github.com/scummvm/scummvm/commit/7abf9ab5fde40b720a43b356f6c46c8de0a468cb
Author: Walter Agazzi (walter.agazzi at protonmail.com)
Date: 2024-05-03T12:49:51+02:00

Commit Message:
AGS: Engine: fixed "mouse up" event could cause a recursive on_event

First "on_event" firing after mouse button is released may cause a sequence of blocking actions.
If there's any control checks during them, the global "wasbutdown" variable will be tested again,
potentially leading to a recursive "mouse up" event, except it's not run immediately, but scheduled
until after the first one has completed running.

For this reason "wasbutdown" must be reset BEFORE firing any events.

This was broken a VERY long time ago, it seems, probably by commit 2f54a16
>From upstream ff1baccbffd8ee79fe3a5aff547e2ac7b8d8aaf5 (branch 3.6.1)

Changed paths:
    engines/ags/engine/main/game_run.cpp


diff --git a/engines/ags/engine/main/game_run.cpp b/engines/ags/engine/main/game_run.cpp
index 1ecce7d80fc..a1557502572 100644
--- a/engines/ags/engine/main/game_run.cpp
+++ b/engines/ags/engine/main/game_run.cpp
@@ -195,8 +195,9 @@ static void check_mouse_controls() {
 	if ((_G(wasbutdown) > kMouseNone) && (ags_misbuttondown(_G(wasbutdown)))) {
 		gui_on_mouse_hold(_G(wasongui), _G(wasbutdown));
 	} else if ((_G(wasbutdown) > kMouseNone) && (!ags_misbuttondown(_G(wasbutdown)))) {
-		gui_on_mouse_up(_G(wasongui), _G(wasbutdown));
-		_G(wasbutdown) = kMouseNone;
+		eAGSMouseButton mouse_btn_up = _G(wasbutdown);
+		_G(wasbutdown) = kMouseNone; // reset before event, avoid recursive call of "mouse up"
+		gui_on_mouse_up(_G(wasongui), mouse_btn_up);
 	}
 
 	eAGSMouseButton mbut;




More information about the Scummvm-git-logs mailing list