fix(tracker): ID collisions in ClearUnit and Instruments.unmarshal

This commit is contained in:
5684185+vsariola@users.noreply.github.com
2024-09-07 15:20:12 +03:00
parent 9da6c2216c
commit 74972b5ff4
4 changed files with 20 additions and 4 deletions

View File

@ -408,6 +408,18 @@ func (m *Model) send(message interface{}) {
m.modelMessages <- message
}
func (m *Model) maxID() int {
maxID := 0
for _, instr := range m.d.Song.Patch {
for _, unit := range instr.Units {
if unit.ID > maxID {
maxID = unit.ID
}
}
}
return maxID
}
func (m *Model) assignUnitIDs(units []sointu.Unit) {
maxId := 0
usedIds := make(map[int]bool)