From 00b1bf3f5bc0e74f46ccf9375d828ebfd5096c07 Mon Sep 17 00:00:00 2001 From: reuk Date: Wed, 28 Sep 2022 14:38:53 +0100 Subject: [PATCH] DirectoryContentsList: Ensure change notification is sent after search completes This fixes an issue where the FileListComponent might fail to select a file, because the file list reported that it was still loading during the final ChangeListener callback. --- .../juce_DirectoryContentsList.cpp | 38 ++++++++----------- 1 file changed, 16 insertions(+), 22 deletions(-) diff --git a/modules/juce_gui_basics/filebrowser/juce_DirectoryContentsList.cpp b/modules/juce_gui_basics/filebrowser/juce_DirectoryContentsList.cpp index 0aeef06267..75a9f1ddbc 100644 --- a/modules/juce_gui_basics/filebrowser/juce_DirectoryContentsList.cpp +++ b/modules/juce_gui_basics/filebrowser/juce_DirectoryContentsList.cpp @@ -202,33 +202,27 @@ int DirectoryContentsList::useTimeSlice() bool DirectoryContentsList::checkNextFile (bool& hasChanged) { - if (fileFindHandle != nullptr) + if (fileFindHandle == nullptr) + return false; + + if (*fileFindHandle == RangedDirectoryIterator()) { - if (*fileFindHandle != RangedDirectoryIterator()) - { - const auto entry = *(*fileFindHandle)++; - - if (addFile (entry.getFile(), - entry.isDirectory(), - entry.getFileSize(), - entry.getModificationTime(), - entry.getCreationTime(), - entry.isReadOnly())) - { - hasChanged = true; - } - - return true; - } - fileFindHandle = nullptr; isSearching = false; - - if (! wasEmpty && files.isEmpty()) - hasChanged = true; + hasChanged = true; + return false; } - return false; + const auto entry = *(*fileFindHandle)++; + + hasChanged |= addFile (entry.getFile(), + entry.isDirectory(), + entry.getFileSize(), + entry.getModificationTime(), + entry.getCreationTime(), + entry.isReadOnly()); + + return true; } bool DirectoryContentsList::addFile (const File& file, const bool isDir,