Page MenuHomeFeedback Tracker

"removeMissionEventHandler" resizes array of handles resulting in non removal and rpt errors
Closed, ResolvedPublic

Description

If one tries to remove mission event handlers in reverse order they were added

[eh1, eh2, eh3] <- array oh handles
removing in reverse
remove eh3 (index 2) -> [eh1, eh2]
remove eh2 (index 1) -> [eh1]
remove eh1 (index 0) -> []

everything works fine, however if one follows the order they where added, this is what happens:

[eh1, eh2, eh3]
remove eh1 (index 0) -> [eh2, eh3]
remove eh2 (index 1) -> [eh2]
remove eh3 (index 2) -> [eh2] (rpt error "Array index out of range" and event handler is not removed)

Details

Legacy ID
3435637284
Severity
None
Resolution
Fixed
Reproducibility
Always
Category
Scripting
Steps To Reproduce

run the following script:

eh1 = addMissionEventHandler ["Draw3D", {drawIcon3D ["", [1,0,0,1], player modelToWorld [-1,3,1.5], 0, 0, 0, "<1>", 1, 0.05, "PuristaMedium"]}];
eh2 = addMissionEventHandler ["Draw3D", {drawIcon3D ["", [0,1,0,1], player modelToWorld [0,3,1.5], 0, 0, 0, "<2>", 1, 0.05, "PuristaMedium"]}];
eh3 = addMissionEventHandler ["Draw3D", {drawIcon3D ["", [0,0,1,1], player modelToWorld [1,3,1.5], 0, 0, 0, "<3>", 1, 0.05, "PuristaMedium"]}];

you will see 3 icons <1> <2> <3>

now run:

removeMissionEventHandler ["Draw3D", eh3];
removeMissionEventHandler ["Draw3D", eh2];
removeMissionEventHandler ["Draw3D", eh1];

all icons removed successfully. Now do it again:

eh1 = addMissionEventHandler ["Draw3D", {drawIcon3D ["", [1,0,0,1], player modelToWorld [-1,3,1.5], 0, 0, 0, "<1>", 1, 0.05, "PuristaMedium"]}];
eh2 = addMissionEventHandler ["Draw3D", {drawIcon3D ["", [0,1,0,1], player modelToWorld [0,3,1.5], 0, 0, 0, "<2>", 1, 0.05, "PuristaMedium"]}];
eh3 = addMissionEventHandler ["Draw3D", {drawIcon3D ["", [0,0,1,1], player modelToWorld [1,3,1.5], 0, 0, 0, "<3>", 1, 0.05, "PuristaMedium"]}];

3 icons <1> <2> <3>. Now remove event handlers in the order they where added

removeMissionEventHandler ["Draw3D", eh1];
removeMissionEventHandler ["Draw3D", eh2];
removeMissionEventHandler ["Draw3D", eh3];

result <2> and error message in rpt. The event handler is not removed.

Pretty severe issue.

Event Timeline

Killzone_Kid edited Additional Information. (Show Details)
Killzone_Kid set Category to Scripting.
Killzone_Kid set Reproducibility to Always.
Killzone_Kid set Severity to None.
Killzone_Kid set Resolution to Fixed.
Killzone_Kid set Legacy ID to 3435637284.May 7 2016, 7:50 PM
Killzone_Kid edited a custom field.

Seems fixed in today;s dev

oukej added a subscriber: oukej.May 7 2016, 7:50 PM
oukej added a comment.Dec 1 2014, 2:52 PM

Yup :)
Thanks for this and for a nice repro!

Btw, the change was a major one. If you encounter any new issues in music, mission, control or display EH please report back.

Thanks a lot!

CL says it is still ongoing, I guess you had to revamp the whole handler handling, haha

Gundy added a comment.Dec 7 2014, 12:00 PM

What version did this get fixed in? I did not see it show up in the 1.36 change log.

Edit: Just checked. In 1.36 the issue is not fixed.

If you read changelog, it says that the fix is ongoing and includes other EHs, this is probably why it didn't make it into this stable. As for this particular fix, it is ok on DEV

Gundy added a comment.Dec 7 2014, 4:03 PM

Thanks, thought "CL" was referring to some internal place :)