diff options
author | Bastien Bouclet | 2016-08-09 20:06:03 +0200 |
---|---|---|
committer | Eugene Sandulenko | 2017-07-03 08:50:10 +0200 |
commit | ab9b241e50a54384635f3bc35dbb775e0fa3a909 (patch) | |
tree | 9a193fff4aae380e7622e646bd17dbe292e1a059 | |
parent | 9926475937ee5ed6137f747016a72a400e69d48b (diff) | |
download | scummvm-rg350-ab9b241e50a54384635f3bc35dbb775e0fa3a909.tar.gz scummvm-rg350-ab9b241e50a54384635f3bc35dbb775e0fa3a909.tar.bz2 scummvm-rg350-ab9b241e50a54384635f3bc35dbb775e0fa3a909.zip |
MOHAWK: Card event handlers could be called recursively
-rw-r--r-- | engines/mohawk/riven_card.cpp | 41 |
1 files changed, 27 insertions, 14 deletions
diff --git a/engines/mohawk/riven_card.cpp b/engines/mohawk/riven_card.cpp index d064a1709a..0b3d96f981 100644 --- a/engines/mohawk/riven_card.cpp +++ b/engines/mohawk/riven_card.cpp @@ -349,8 +349,13 @@ void RivenCard::onMouseDown(const Common::Point &mouse) { onMouseMove(mouse); _pressedHotspot = _hoveredHotspot; + + RivenScriptPtr script; if (_pressedHotspot) { - RivenScriptPtr script = _pressedHotspot->getScript(kMouseDownScript); + script = _pressedHotspot->getScript(kMouseDownScript); + } + + if (script) { _vm->_scriptMan->runScript(script, false); } } @@ -358,31 +363,39 @@ void RivenCard::onMouseDown(const Common::Point &mouse) { void RivenCard::onMouseUp(const Common::Point &mouse) { onMouseMove(mouse); + RivenScriptPtr script; if (_pressedHotspot && _pressedHotspot == _hoveredHotspot) { - RivenScriptPtr script = _pressedHotspot->getScript(kMouseUpScript); - _vm->_scriptMan->runScript(script, false); + script = _pressedHotspot->getScript(kMouseUpScript); } _pressedHotspot = nullptr; + + if (script) { + _vm->_scriptMan->runScript(script, false); + } } void RivenCard::onMouseMove(const Common::Point &mouse) { RivenHotspot *hotspot = getHotspotContainingPoint(mouse); - if (hotspot) { - if (hotspot != _hoveredHotspot) { - if (_hoveredHotspot) { - RivenScriptPtr script = _hoveredHotspot->getScript(kMouseLeaveScript); - _vm->_scriptMan->runScript(script, false); - } + RivenScriptPtr script = RivenScriptPtr(new RivenScript()); - _hoveredHotspot = hotspot; - RivenScriptPtr script = _hoveredHotspot->getScript(kMouseEnterScript); - _vm->_scriptMan->runScript(script, false); - } - } else { + // Detect hotspot exit + if (_hoveredHotspot && (!hotspot || hotspot != _hoveredHotspot)) { + script += _hoveredHotspot->getScript(kMouseLeaveScript); + } + + // Detect hotspot entry + if (hotspot && hotspot != _hoveredHotspot) { + _hoveredHotspot = hotspot; + script += _hoveredHotspot->getScript(kMouseEnterScript); + } + + if (!hotspot) { _hoveredHotspot = nullptr; } + + _vm->_scriptMan->runScript(script, false); } void RivenCard::onMouseDragUpdate() { |