BR: FileListComponent::setSelectedFile()

There is a bug where FileListComponent::setSelectedFile() won’t work when the directoryContentsList has just been given a new directory and is still loading.

The issue is that FileListComponent::lastDirectory isn’t updated immediately when directoryContentsList.setDirectory() is called, and so fileWaitingToBeSelected is cleared as soon as FileListComponent::changeListenerCallback() is called here:

Here is a PIP to reproduce (a FileListComponent loading the /Applications folder and trying to select /Applications/Utilities)

PIP
/*******************************************************************************
 The block below describes the properties of this PIP. A PIP is a short snippet
 of code that can be read by the Projucer and used to generate a JUCE project.

 BEGIN_JUCE_PIP_METADATA

  name:             TestPip

  dependencies:     juce_core, juce_data_structures, juce_events, juce_graphics, juce_gui_basics
  exporters:        XCODE_MAC

  moduleFlags:      JUCE_STRICT_REFCOUNTEDPOINTER=1

  type:             Component
  mainClass:        MyComponent

 END_JUCE_PIP_METADATA

*******************************************************************************/

#pragma once


//==============================================================================
class MyComponent  : public juce::Component
{
public:
    //==============================================================================
    MyComponent()
    {
        addAndMakeVisible (fileListComponent);
        timeSliceThread.startThread();

        auto applicationsDir = File::getSpecialLocation (File::globalApplicationsDirectory);
        directoryContentsList.setDirectory (applicationsDir, File::findFilesAndDirectories, true);
        fileListComponent.setSelectedFile (applicationsDir.getChildFile ("Utilities"));
        setSize (600, 400);
    }

    //==============================================================================
    void paint (juce::Graphics& g) override { g.fillAll (Colours::white); }
    void resized() override { fileListComponent.setBounds (getLocalBounds()); }

private:
    //==============================================================================
    TimeSliceThread timeSliceThread { "timeSliceThread" };
    DirectoryContentsList directoryContentsList { nullptr, timeSliceThread };
    FileListComponent fileListComponent { directoryContentsList };
    JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MyComponent)
};
1 Like

let me know if you can’t reproduce with the provided PIP.
a fix would be welcome! :slight_smile:
it doesn’t seem possible to have a reliable FileListComponent without dirty workarounds atm

bump. Would love to see this bug fixed at some point :slight_smile:
let me know if you can’t reproduce with the provided pip.

I would appreciate some minimal feedback regarding that.
something like “we fixed it”, or “we’re aware of it but this is tricky to fix”, or “we can’t reproduce with the provided pip”, or “it’s not a bug it’s a feature”, or anything really

1 Like

Haven’t tested yet, but I guess this commit is about fixing that bug?

Not sure what to think about the lack of any feedback here.
It takes time to send bug reports and write pips to reproduce rather than just fixing it locally, so please let us now if you’re not interested by bugs reports or if reporting via the forum isn’t the way to go anymore.

1 Like

Apologies for missing this thread when releasing the fix.

In this case, it slipped through, because the bug was reported independently, and a message about the fix was posted only in the other thread. It’s highly likely that the issue experienced by you is also fixed by said commit.

Bug reports are always appreciated and thank you for also sharing code for reproduction.

1 Like

honestly this thread just made me feel a bit like a spammer.
It feels like my bug report wasn’t taken into account at all although i was frequently ‘bumping’ it, and that somehow someone else reports it and you fix it within a month. I wouldn’t mind getting a feedback like ‘we’ve received your bug report, give us a couple of years to take a look at it’, but the silence wasn’t comfortable.

The lack of feedback to BR/FR on the forum has been a recurrent complain over the years (e.g Is the JUCE team still here? - #11 by lalala ).

1 Like