Closed jakubgondek closed 11 years ago
I think that’s because the same command gets executed more than once in EventCommandExecutor.execute(), even when guardsApprove returns false, in case there are 2 or more mappings for the same event type.
On line 81:
For each mapped guard, if guardsApprove returns true, a command is instantiated:
command = _injector.instantiateUnmapped(commandClass);
and then
if(command)
{
mapping.fireOnce && _trigger.removeMapping(mapping);
command.execute();
}
If there are 2 or more mappings for the same event, in case guardsApprove returns false for the subsequent mappings, the command should be null or flagged as executed.
I haven’t run any tests, I just did this:
if (mapping.guards.length == 0 || guardsApprove(mapping.guards, _injector))
{
command = _injector.instantiateUnmapped(commandClass);
//rest of the code…
}
else
{
command = null;
}
And after that it worked as expected. Though, I’m not sure if this solves the issue, or if the code will explode because of the change. Shaun will know :)
@jakubgondek Thanks for catching that. @Ondina Thanks for pointing me in the right direction!
Hi,
I'm not an experienced Robotlegs user, so code below may not follow best practices, but it certainly acts a bit weird.
Here is the trace that I get:
OnlyIfCondition1: false OnlyIfCondition2: true Command 2 executed OnlyIfCondition1: true Command 1 executed OnlyIfCondition2: false Command 1 executed
and here is what I would expect:
OnlyIfCondition1: false OnlyIfCondition2: true Command 2 executed OnlyIfCondition1: true OnlyIfCondition2: false Command 1 executed
I'm using Robotlegs 2.0.0b4
Best regards Jakub Gondek
PS. Sory for the markdown issues if any.