[Fixed 2.8 Beta] Renoise.song().pattern_Iterator Does Not Update Corre


when executing following code when inserting a new track, it seems the pattern-iterator does not update the index of the inserted track correctly on the first run. When inserting a track again, the output is correct for the previously inserted track (not for the current inserted).

function load_pattern_into_sequencer()  
 local pattern_iter = renoise.song().pattern_iterator  
 local pattern_index = renoise.song().selected_pattern_index  
 print('track one')  
 for pos,line in pattern_iter:lines_in_pattern_track(pattern_index,1) do  
 print('track two')  
 for pos,line in pattern_iter:lines_in_pattern_track(pattern_index,2) do  

E.g. paste above code into the TestPad.lua and add a note say C-1 to the first position of Track1 and C-2 to the first position of Track 2. If you then insert a new track between the two tracks (so having a new empty Track2) the load_pattern_into_sequencer() function is executed.
We expect an output of C-1 for Track1 and an empty row for Track2, because we inserted a new Track as Track2. But the output for Track2 is still C-2, so it seems the pattern iterator did not update the index. Instead, the empty inserted track was appended to the end of all tracks (say before insertion we have 5 tracks, the new inserted is at position 6 now)

If we insert a track again, the previously added track is at the right index, whereas the currently added track is at the end of the tracks again.

Is there probably a way to fix this or is there a workaround?

I would like to bump this topic, because the bug is still there in 2.72. I made some tests and the new inserted track is still appended at the track-list index the pattern_iterator uses, but not inserted at the given position.

See I Need Help With Tracks_Observable please. It’s basically the same problem: the track is not yet fully inserted while the notifier gets called. Aka, the iterator is not the problem, but doing this in the notifier is.

This one shot idle thing (see linked thread above) will fix the problem in your case too, until we’ve fixed this properly…

Thanks, that fixed it for now. :)

Have you tested 2.8? this should now have been fixed in 2.8 without needing the one-shot idle notifier.