scummvm/scummvm — pull request #351 by bluegr (2013-07-05 10:23:14+00:00)
Title: Don't allow the event recorder and the keymapper to be enabled simultaneously

Currently, the event recorder and the keymapper cannot be enabled simultaneously. If they are both enabled, ScummVM will crash on startup, as the event recorder replaces the keymapper as an event source. The keymapper then tries to map default keys to the event recorder, leading to a crash.

In particular, DefaultEventManager does:

_dispatcher.registerMapper(_keymapper);

but then the event recorder does:

g_system->getEventManager()->getEventDispatcher()->registerMapper(this, false);

There is a comment above registerMapper() in the EventDispatcher class that mentions:

* @param autoFree	Destroy previous mapper [default]
*	Normally we allow only one event mapper to exists,
*	However Event Recorder must intervent into normal
*	event flow without altering its semantics. Thus during
*	Event Recorder playback and recording we allow
*	two mappers.

However this isn't true: currently, registerMapper() does not handle a list of event mappers, and it just replaces the keymapper with the event recorder.

The problem is a bit more complicated, as the event recorder is supposed to record backend events too. Plus, there are some cases where both the event recorder and the keymapper will need to be handled as event mappers.

One possible suggestion would be to totally separate the keymapper and event recorder as event mappers, and call them both in all places where the event mapping code is used.

As it stands now, these two features just can't be used together, hence this pull request that prevents the user from enabling them both, for now