mirror of
https://github.com/vsariola/sointu.git
synced 2025-07-19 05:24:48 -04:00
fix(tracker): ID collisions in ClearUnit and Instruments.unmarshal
This commit is contained in:
parent
9da6c2216c
commit
74972b5ff4
@ -269,11 +269,13 @@ func (v *Instruments) unmarshal(data []byte) (from, to int, err error) {
|
||||
if v.d.Song.Patch.NumVoices()+newInstr.Patch.NumVoices() > vm.MAX_VOICES {
|
||||
return 0, 0, fmt.Errorf("InstrumentListView.unmarshal: too many voices: %d", v.d.Song.Patch.NumVoices()+newInstr.Patch.NumVoices())
|
||||
}
|
||||
patch := append(v.d.Song.Patch, make([]sointu.Instrument, len(newInstr.Patch))...)
|
||||
v.d.Song.Patch = append(v.d.Song.Patch, make([]sointu.Instrument, len(newInstr.Patch))...)
|
||||
sel := v.Selected()
|
||||
copy(patch[sel+len(newInstr.Patch):], patch[sel:])
|
||||
copy(patch[sel:sel+len(newInstr.Patch)], newInstr.Patch)
|
||||
v.d.Song.Patch = patch
|
||||
copy(v.d.Song.Patch[sel+len(newInstr.Patch):], v.d.Song.Patch[sel:])
|
||||
for i := 0; i < len(newInstr.Patch); i++ {
|
||||
(*Model)(v).assignUnitIDs(newInstr.Patch[i].Units)
|
||||
v.d.Song.Patch[sel+i] = newInstr.Patch[i]
|
||||
}
|
||||
from = sel
|
||||
to = sel + len(newInstr.Patch) - 1
|
||||
return
|
||||
|
Reference in New Issue
Block a user