prepare for better ins del safety

This commit is contained in:
tildearrow 2022-01-13 17:40:29 -05:00
parent fea783eaac
commit 0545775de6
3 changed files with 12 additions and 0 deletions

View file

@ -196,6 +196,11 @@ class DivDispatch {
*/ */
void setSkipRegisterWrites(bool value); void setSkipRegisterWrites(bool value);
/**
* notify deletion of an instrument.
*/
virtual void notifyInsDeletion(void* ins);
/** /**
* force-retrigger instruments. * force-retrigger instruments.
*/ */

View file

@ -2706,6 +2706,9 @@ int DivEngine::addInstrument(int refChan) {
void DivEngine::delInstrument(int index) { void DivEngine::delInstrument(int index) {
isBusy.lock(); isBusy.lock();
if (index>=0 && index<(int)song.ins.size()) { if (index>=0 && index<(int)song.ins.size()) {
for (int i=0; i<song.systemLen; i++) {
disCont[i].dispatch->notifyInsDeletion(song.ins[index]);
}
delete song.ins[index]; delete song.ins[index];
song.ins.erase(song.ins.begin()+index); song.ins.erase(song.ins.begin()+index);
song.insLen=song.ins.size(); song.insLen=song.ins.size();

View file

@ -46,6 +46,10 @@ void DivDispatch::setSkipRegisterWrites(bool value) {
skipRegisterWrites=value; skipRegisterWrites=value;
} }
void DivDispatch::notifyInsDeletion(void* ins) {
}
void DivDispatch::forceIns() { void DivDispatch::forceIns() {
} }