This is an odd issue:
When having multiple markers on the same position, SetProjectMarkerByIndex sometimes gets confused about which marker to address.
I made it happen with the following setup:
Add multiple markers with different names on position 30 secs in the project (A, B, C, etc).
Then I ran this code-line multiple times, which should change the name of the first marker found to Oops:
Code:
reaper.SetProjectMarkerByIndex(0, 1, false, 30, 0, 1, "Oops", 0)
Now what I would expect is, that running this multiple times changes the name of the first marker found to Oops once and leaving all others untouched.
However, sometimes, it "finds" different markers as first ones, so multiple markers get renamed. This is not always the case. Sometimes it works as expected for a long time and out of a sudden: boom.
It looks like Reaper treats multiple markers on the same position as equal, though they are not. And as Reaper sees them as equal, it seems to be, as if it changes the first marker found in memory or something, which might be Marker A or Marker B or Marker C, depending on what the memory does(though I might be wrong about this guess...).
I tried numerous workarounds but they all didn't work out.
I tried to code a Renumerate-Markers-function, where I go through all of them to give them a new shown-number, which worked, when I coded it initially. And suddenly, it stopped, skipping markers. After some bughunting, I found, that SetProjectMarkerByIndex is already the culprit.
Haven't checked SetProjectMarkerByIndex2.
Funny sidenote:
You can pass 0 as parameter isrgn. I made this parameter=0 instead of false and I initially thought, this is the bug. But it isn't.
Tested on Reaper 6.64x64 on Windows 7. Since you didn't change marker-stuff since then, I guess, the issue still persists.
PS: We need an "UpdateMarkerList"-function. I currently need to click into the markerlist or even the marker/region/takemarkers-visibility-checkboxes to see such changes when debugging scripts, which is possible but really tedious...
Edit: It's so frustrating, that it's not easy to reproduce. It sometimes happens for a minute or so and out of a sudden, everything is working fine. Some minutes later, the issue kicks in again.
All I could found, that running a defer-script for some time, doing the above code line, doesn't show the issue.
It seems like it's happening somehow at the initialization of Lua(?). As if Lua gets a list of markers to work with but it might change from creating an instance to the next creating an instance.
Like a table in Lua, whose elements aren't indexed. When you use pair on them, the order of the returned elements may change or be the same....