--- qsampler/trunk/src/qsamplerInstrumentList.cpp 2010/03/15 17:06:46 2070 +++ qsampler/trunk/src/qsamplerInstrumentList.cpp 2010/03/15 18:21:28 2071 @@ -190,7 +190,9 @@ // with the very same key (bank, program); // if yes, just remove it without prejudice... InstrumentList& list = m_instruments[iMap]; - for (int i = 0; i < list.size(); ++i) { + + int i = 0; + for ( ; i < list.size(); ++i) { const Instrument *pInstr = list.at(i); if (pInstr->bank() == iBank && pInstr->prog() == iProg) { delete pInstr; @@ -200,8 +202,7 @@ } // Resolve the appropriate place, we keep the list sorted that way... - int i = 0; - for ( ; i < list.size(); ++i) { + for (i = 0; i < list.size(); ++i) { const Instrument *pInstr = list.at(i); if (iBank < pInstr->bank() || (iBank == pInstr->bank() && iProg < pInstr->prog())) { @@ -223,16 +224,13 @@ void InstrumentListModel::removeInstrument ( Instrument *pInstrument ) { - const int iMap = pInstrument->map(); - const int iBank = pInstrument->bank(); - const int iProg = pInstrument->prog(); + const int iMap = pInstrument->map(); if (m_instruments.contains(iMap)) { InstrumentList& list = m_instruments[iMap]; for (int i = 0; i < list.size(); ++i) { - const Instrument *pInstr = list.at(i); - if (pInstr->bank() == iBank && pInstr->prog() == iProg) { - delete pInstr; + if (pInstrument == list.at(i)) { + delete pInstrument; list.removeAt(i); break; }