Corrected a bug when reloading files, where the string views used for the FilePool hash table where pointing towards freed memory.

This commit is contained in:
paulfd 2019-09-16 15:11:15 +02:00
parent 5b17f727d8
commit e028fdced9
3 changed files with 10 additions and 0 deletions

View file

@ -121,3 +121,11 @@ void sfz::FilePool::loadingThread() noexcept
fileToLoad.voice->setFileData(readFromFile<float>(sndFile, fileToLoad.numFrames), fileToLoad.ticket); fileToLoad.voice->setFileData(readFromFile<float>(sndFile, fileToLoad.numFrames), fileToLoad.ticket);
} }
} }
void sfz::FilePool::clear()
{
preloadedData.clear();
while(loadingQueue.pop()){
// Pop the queue
}
}

View file

@ -59,6 +59,7 @@ public:
}; };
std::optional<FileInformation> getFileInformation(std::string_view filename, uint32_t offset) noexcept; std::optional<FileInformation> getFileInformation(std::string_view filename, uint32_t offset) noexcept;
void enqueueLoading(Voice* voice, std::string_view sample, int numFrames, unsigned ticket) noexcept; void enqueueLoading(Voice* voice, std::string_view sample, int numFrames, unsigned ticket) noexcept;
void clear();
private: private:
std::filesystem::path rootDirectory; std::filesystem::path rootDirectory;
struct FileLoadingInformation { struct FileLoadingInformation {

View file

@ -119,6 +119,7 @@ void sfz::Synth::clear()
masterOpcodes.clear(); masterOpcodes.clear();
groupOpcodes.clear(); groupOpcodes.clear();
regions.clear(); regions.clear();
filePool.clear();
} }
void sfz::Synth::handleGlobalOpcodes(const std::vector<Opcode>& members) void sfz::Synth::handleGlobalOpcodes(const std::vector<Opcode>& members)