Iterate gets stuck when list Is changed

Forums 💬 NodeCanvas ⚙️ Support Iterate gets stuck when list Is changed

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #16840
    wanderfalke
    Participant

      I noticed that Iterate gets stuck when the last list element is removed while being executed.

      The reason is, that the following if-condition is not entered as currentIndex > list.Count-1.

      The following calls to Iterate’s OnExecute method skip the whole for-loop as currentIndex > list.Count. The list is therefore forever stuck in Status.Running.

      As I simple fix, I changed the if check to a greater or equal check:

      I know this is an edge case but it is also an edge case that is easy to fix 😉

      #16844
      Gavalakis
      Keymaster

        Thank you for the fix! I will do that as well  😉

        #16843
        wanderfalke
        Participant

          I just noticed that the iterator gets stuck if list.Count gets reduced after the iterator was executed.

          E.g. Iterator was executed -> element is removed from list -> interator is executed again.

          I added

          infront of the iterator’s for loop.

          made some small modification to currentIndex==maxIteration.value -1 aswell. MaxIteration could be changed during runtime. If currentIndex > maxIteration, I would expect the loop not to continue with its normal operation.

          #16842
          Gavalakis
          Keymaster

            Hey,

            Do you mind posting the full Iterator.cs code just to double check your changes please? 🙂
            Thank you!

            #16841
            wanderfalke
            Participant

              This is the iterator as we are currently using it.
              Note:

              • It contains also the temporary changes to GetEnumerableElementType we discussed in another thread).
              • We split resetIndexOnReset to resetIndexOnReset and resetIndexAfterIteration. This might change the behavior of already existing iterators (with resetIndexOnReset  set to false).
            Viewing 5 posts - 1 through 5 (of 5 total)
            • You must be logged in to reply to this topic.