if (filename.isNotEmpty())
setFileName (filename);
to have no effect. At that point directoryContentsList.getNumFiles() is already updated but ListBox::totalItems is still not, so FileListComponent::setSelectedFile() finds the file, but ListBox::selectRow() does not select the row, and it’s not marked as waiting to be selected.
A possible fix here. FileListComponent waits until the load has finished before selecting files. It’s working in my case, but I think it’s still possible for it to fail, if the contents list has finished loading but the last message is still pending.
It doesn’t work here. Even if the DirectoryContentsList has finished loading on its own thread, the changes need to be pulled by the FileListComponent from the message thread through the ChangeListener callback so that updateContent() is called and ListBox::totalItems is updated.
Just in case this was the fix, it still doesn’t work. I don’t think it’s possible to fix this issue on DirectoryContentsList’s side. The problem is that ListBox::selectRow() depends on updateContent() having been called to actually update the rows. It’s not enough for the notification to have been sent, it needs to have arrived.