Objects skipped by UpdateAll

I don`t know whether it is a bug. But when the first object of the list of objects is deleted in orxObject_UpdateAll(), the second object is skipped in the current processing, it is only updated in the next one.

I think this could cause problems if someone is looking for an object by its name and expects to not find it after its life time ends.
  for(pstObject = orxOBJECT(orxStructure_GetFirst(orxSTRUCTURE_ID_OBJECT));
      pstObject != orxNULL;
      pstObject = orxOBJECT(orxStructure_GetNext(pstObject)))
  {
          (...)

          /* Stores object to delete */
          pstDeleteObject = pstObject;

          /* Reverts to previous object */
          pstObject = orxOBJECT(orxStructure_GetPrevious(pstObject));

          /* Deletes it */
          orxObject_Delete(pstDeleteObject);

          /* Is previous invalid? */
          if(pstObject == orxNULL)
          {
            pstObject = orxOBJECT(orxStructure_GetFirst(orxSTRUCTURE_ID_OBJECT));

            /* Was the last one? */
            if(pstObject == orxNULL)
            {
              /* Stops */
              break;
            }
          }

          (...)
  }

After the first object is deleted and the code checks if the previous object is valid, it gets the first object of the list, but then the FOR calls the GetNext skipping the previous object.

Hope I was clear.

Comments

  • edited May 2011
    Yep, definitely a bug!
    Thanks for finding it, I'll fix it tonight. :)
  • edited May 2011
    Should be fixed. Please let me know! :)
  • edited May 2011
    It is working fine now.

    Thanks.
Sign In or Register to comment.