Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions source/jucePluginEditorLib/patchmanager/patchmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,16 @@ namespace jucePluginEditorLib::patchManager
results.assign(_search.results.begin(), _search.results.end());

if(results.empty())
{
// the search found no match, but it must still be cancelled/removed from the DB's
// search list, otherwise it leaks forever and every subsequent bank load / patch
// update has to scan it in DB::updateSearches, causing CPU usage to grow unbounded
runOnUiThread([this, handle]
{
cancelSearch(handle);
});
return;
}

if(results.size() > 1)
{
Expand Down
9 changes: 8 additions & 1 deletion source/jucePluginLib/patchdb/db.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,14 @@ namespace pluginLib::patchDB
return;

std::unique_lock lock(m_searchesMutex);
m_cancelledSearches.insert(_handle);

// only remember the handle as cancelled if the search may still be picked up by executeSearch
// later (i.e. it's still queued/running). A search that has already completed will never be
// looked at again, so tracking it here would leak the handle in m_cancelledSearches forever.
const auto it = m_searches.find(_handle);
if(it != m_searches.end() && it->second->state != SearchState::Completed)
m_cancelledSearches.insert(_handle);

m_searches.erase(_handle);
}

Expand Down