Page MenuHomeFeedback Tracker

Removing an event handler from inside the EH code will cause the next event handler to be skipped
Assigned, NormalPublic

Description

Here's a simple code to demonstrate the problem:

player allowDamage false;
player addEventHandler ["HandleDamage", {
   systemChat "EH 1";
   _this#0 removeEventHandler ["HandleDamage", _thisEventHandler];
}];
player addEventHandler ["HandleDamage", {systemChat "EH 2"}];

player setVelocity [0,0,-100];

The above code will only show "EH 1". If the removeEventHandler line is commented out, both systemChats will be shown.

This bug is similar to doing:

_array = [1,2,3,4,5,6];
_newArray = [];
{
  _newArray pushBack _x;
  _array deleteAt _forEachIndex;
} forEach _array;

which will give [1,3,5]

Details

Severity
Minor
Resolution
Open
Reproducibility
Always
Operating System
Windows 10 x64
Category
Scripting

Event Timeline

Leopard20 updated the task description. (Show Details)Nov 9 2021, 11:07 PM
Leopard20 updated the task description. (Show Details)Nov 9 2021, 11:10 PM
h- added a subscriber: h-.Nov 10 2021, 8:01 AM

should be fixed in rev.148471

BIS_fnc_KK removed BIS_fnc_KK as the assignee of this task.Nov 11 2021, 9:33 AM
BIS_fnc_KK changed the task status from New to Feedback.
BIS_fnc_KK added a subscriber: BIS_fnc_KK.
dedmen claimed this task.Nov 11 2021, 11:55 AM
dedmen changed the task status from Feedback to Assigned.
dedmen set Ref Ticket to AIII-54722.

Fix coming to dev branch this week (I think there will be one this week) and profiling branch