This commit fixes removing sleeps in "resetsleep" function.

To test this bug make, for example, 3 long-standing sleeps, add checking of number of sleeps before and after existing "loopv(sleep)",
and later  type "/resetsleeps" command in AC - result: 3 sleeps "before" and 1 remains "after".

Explanation by stef: after deleting elements from vectors there are no holes,
so if there were sleeps[0], sleeps[1] and sleeps[2], then after removing sleeps[0] there left
sleeps[0] and sleeps[1], so during next loop cycle this sleeps[0] is neglected (because i=1).

Commit just changes loopv to loopvrev (loop from end to begin).
This commit is contained in:
aurhat
2014-02-15 10:55:07 +01:00
parent 9197de052f
commit ef165773b8
+1 -1
View File
@@ -599,7 +599,7 @@ void addsleep_(int *msec, char *cmd, int *persist)
void resetsleep(bool force)
{
loopv(sleeps) if(!sleeps[i].persist || force)
loopvrev(sleeps) if(!sleeps[i].persist || force)
{
DELETEA(sleeps[i].cmd);
sleeps.remove(i);