Skip to content

Commit

Permalink
Merge pull request plugdata-team#1791 from plugdata-team/develop
Browse files Browse the repository at this point in the history
Fix plugin shutdown bug
  • Loading branch information
timothyschoen authored Aug 10, 2024
2 parents e213743 + f4a2f08 commit ab8db68
Showing 1 changed file with 26 additions and 12 deletions.
38 changes: 26 additions & 12 deletions Source/Sidebar/DocumentationBrowser.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ class DocumentationBrowserUpdateThread : public Thread

~DocumentationBrowserUpdateThread()
{

instance = nullptr;
stopThread(-1);
}
Expand Down Expand Up @@ -202,20 +203,33 @@ class DocumentationBrowserUpdateThread : public Thread
}
}

void run() override
{
try
{
fileTreeLock.enter();
fileTree = generateDirectoryValueTree(File(SettingsFile::getInstance()->getProperty<String>("browser_path")));
fileTreeLock.exit();
sendChangeMessage();
}
catch(...)
void run() override
{
std::cerr << "Failed to update documentation browser" << std::endl;
try
{
int const maxRetries = 50;
int retries = 0;

while (retries < maxRetries) {
if (threadShouldExit())
break;
if (fileTreeLock.tryEnter()) {
fileTree = generateDirectoryValueTree(File(SettingsFile::getInstance()->getProperty<String>("browser_path")));
fileTreeLock.exit();
break;
}
retries++;
Time::waitForMillisecondCounter(Time::getMillisecondCounter() + 100);
}


sendChangeMessage();
}
catch(...)
{
std::cerr << "Failed to update documentation browser" << std::endl;
}
}
}

void filesystemChanged() override
{
Expand Down

0 comments on commit ab8db68

Please sign in to comment.