Skip to content

Commit

Permalink
Fix potential deadlock
Browse files Browse the repository at this point in the history
  • Loading branch information
timothyschoen committed Nov 7, 2024
1 parent dc2cb8c commit 8ab69e9
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions Source/Sidebar/DocumentationBrowser.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class DocumentationBrowserUpdateThread : public Thread
ValueTree getCurrentTree()
{
ScopedLock treeLock(fileTreeLock);
return fileTree;
return fileTree.createCopy();
}

static DocumentationBrowserUpdateThread* getInstance()
Expand Down Expand Up @@ -212,9 +212,10 @@ class DocumentationBrowserUpdateThread : public Thread
while (retries < maxRetries) {
if (threadShouldExit())
break;
if (fileTreeLock.tryEnter()) {

const ScopedTryLock stl (fileTreeLock);
if (stl.isLocked()) {
fileTree = generateDirectoryValueTree(File(SettingsFile::getInstance()->getProperty<String>("browser_path")));
fileTreeLock.exit();
break;
}
retries++;
Expand All @@ -223,6 +224,7 @@ class DocumentationBrowserUpdateThread : public Thread

sendChangeMessage();
} catch (...) {

std::cerr << "Failed to update documentation browser" << std::endl;
}
}
Expand Down

0 comments on commit 8ab69e9

Please sign in to comment.