Trying to correct a segfault, some shenanigans with vectors of shared pointers?

This commit is contained in:
paulfd 2019-09-18 09:14:03 +02:00
parent 234105c34c
commit 4d70ed5b73

View file

@ -131,8 +131,8 @@ void sfz::FilePool::loadingThread() noexcept
SndfileHandle sndFile(reinterpret_cast<const char*>(file.c_str()));
std::lock_guard guard { fileHandleMutex };
auto newHandle = fileHandles.emplace_back(readFromFile<float>(sndFile, fileToLoad.numFrames));
fileToLoad.voice->setFileData(newHandle, fileToLoad.ticket);
fileHandles.emplace_back(readFromFile<float>(sndFile, fileToLoad.numFrames));
fileToLoad.voice->setFileData(fileHandles.back(), fileToLoad.ticket);
}
}
@ -141,7 +141,6 @@ void sfz::FilePool::garbageThread() noexcept
while (!quitThread) {
for (auto handle = fileHandles.begin(); handle < fileHandles.end();) {
if (handle->use_count() == 1) {
handle->reset();
std::lock_guard guard { fileHandleMutex };
std::iter_swap(handle, fileHandles.end() - 1);
fileHandles.pop_back();