From: <rel...@us...> - 2011-12-29 17:13:22
|
Revision: 1148 http://modplug.svn.sourceforge.net/modplug/?rev=1148&view=rev Author: relabsoluness Date: 2011-12-29 17:13:15 +0000 (Thu, 29 Dec 2011) Log Message: ----------- [Fix] Instrument editor: When dragging instruments from tree view, new instrument could override sample from existing instrument (broken in rev 1022). [Mod] Instrument editor: When adding new instruments, the new instrument can't no longer get sample index which points to existing but unreferenced sample. Revision Links: -------------- http://modplug.svn.sourceforge.net/modplug/?rev=1022&view=rev Modified Paths: -------------- trunk/OpenMPT/mptrack/Modedit.cpp trunk/OpenMPT/soundlib/Dlsbank.cpp Modified: trunk/OpenMPT/mptrack/Modedit.cpp =================================================================== --- trunk/OpenMPT/mptrack/Modedit.cpp 2011-12-11 22:50:59 UTC (rev 1147) +++ trunk/OpenMPT/mptrack/Modedit.cpp 2011-12-29 17:13:15 UTC (rev 1148) @@ -550,6 +550,8 @@ newsmp = nSample; } else if (!pDup) { + newsmp = m_SndFile.GetNextFreeSample(newins); + /* for(SAMPLEINDEX k = 1; k <= m_SndFile.GetNumSamples(); k++) { if (!m_SndFile.IsSampleUsed(k)) @@ -560,9 +562,11 @@ } } if (!newsmp) + */ + if (newsmp > m_SndFile.GetNumSamples()) { // Add a new sample - int inssmp = InsertSample(); + const SAMPLEINDEX inssmp = InsertSample(); if (inssmp != SAMPLEINDEX_INVALID) newsmp = inssmp; } } Modified: trunk/OpenMPT/soundlib/Dlsbank.cpp =================================================================== --- trunk/OpenMPT/soundlib/Dlsbank.cpp 2011-12-11 22:50:59 UTC (rev 1147) +++ trunk/OpenMPT/soundlib/Dlsbank.cpp 2011-12-29 17:13:15 UTC (rev 1148) @@ -1739,11 +1739,7 @@ nSmp = RgnToSmp[nRgn-1]; } else { - // Find a nice sample slot - do - { - nSample++; - } while (nSample < pSndFile->GetNumSamples() && (pSndFile->GetSample(nSample).pSample != nullptr || pSndFile->m_szNames[nSample][0])); + nSample = pSndFile->GetNextFreeSample(nInstr); if (nSample >= MAX_SAMPLES) break; if (nSample > pSndFile->GetNumSamples()) pSndFile->m_nSamples = nSample; nSmp = nSample; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |