FileBrowserComponent: initial file not selected after recent commit

This commit causes this

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.

Thanks for reporting, this should be fixed on develop:

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.

Sorry about that, I thought it was working but it looks like it might still fail intermittently. I’ll put a fix together.

1 Like

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.