1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

DirectoryContentsList: Start thread before attempting to scan files

This fixes an issue where opening a FileTreeComponent could cause the UI
to hang. The call to subcontentsList->isStillLoading() in
FileListTreeItem::selectFile() would always return true because the
file-scanner TimeSliceThread wasn't started until the selectFile() call
finished.
This commit is contained in:
reuk 2022-08-31 16:15:59 +01:00
parent a1bb7aeead
commit 21c214aec8
No known key found for this signature in database
GPG key ID: FCB43929F012EE5C
2 changed files with 4 additions and 3 deletions

View file

@ -27,7 +27,7 @@ namespace juce
{
DirectoryContentsList::DirectoryContentsList (const FileFilter* f, TimeSliceThread& t)
: fileFilter (f), thread (t)
: fileFilter (f), thread (t)
{
}

View file

@ -63,6 +63,9 @@ FileBrowserComponent::FileBrowserComponent (int flags_,
filename = initialFileOrDirectory.getFileName();
}
// The thread must be started before the DirectoryContentsList attempts to scan any file
thread.startThread (4);
fileList.reset (new DirectoryContentsList (this, thread));
fileList->setDirectory (currentRoot, true, true);
@ -122,8 +125,6 @@ FileBrowserComponent::FileBrowserComponent (int flags_,
if (filename.isNotEmpty())
setFileName (filename);
thread.startThread (4);
startTimer (2000);
}