FileChooserDialogBox with a FilePreviewComponent has bugs on OSX


#1

Like the title, if the FileChooserDialogBox's FileBrowserComponent has a FilePreviewComponent and set to openMode and canSelectFiles, make the FileChooserDialogBox showing up, then click to select or double click try to open a folder, the code will hit the jassert see below, in the source file juce_FileInputStream.cpp, line 78: 

// You should always check that a stream opened successfully before using it!
jassert (openedOk());

By this time, if you 'Continue' debugging, it'll hit 2 jasserts repeatedly many times (Line 78 and 53), after that, all normal again, just like nothing had happened...


#2

Sorry, can't reproduce that..

It's not very helpful to just give the exact position of the assertion - the important info here is the location from which that was called.

But are you sure this isn't a bug in your own code? The juce demo's image preview test works fine for me. How would I actually reproduce what you're seeing?


#3

Sorry about waste your time, Jules. I can imagine how annoyed my posts are... but if I could location the wrong code, I would have solved it alreay, so why would I spent so many time ask so many stupid questions? I hate myself...

JUCE-Demo used FileChooser instead of FileChooserDialogBox directly. I know this problem absolutly couldn't reproduce with FileChooser, which I always use and like it (unfortunately, Android doesn't). I'm not sure whether my code has bugs or not since this is the first time I dealing with FileChooserDialogBox, but it seems ok to me. Please check it below:

WildcardFileFilter wildcardFilter ("*.jpg;*.png", String::empty, "Image files");
ImagePreviewComponent previewComponent;

FileBrowserComponent browser (FileBrowserComponent::openMode |
                              FileBrowserComponent::canSelectFiles,
                              File::nonexistent, 
                              &wildcardFilter, 
                              &previewComponent);

FileChooserDialogBox dialogBox ("Open an image file", "Please choose...",
                                browser, false, Colours::lightgrey);

if (dialogBox.show())
    // ...

It's simple to reproduce the problem, just compile the code above on OSX and click a folder. Sorry I'm going to waste your time again...

I tried to track it. After many many assembler codes, the last line before hit the jassert is: 
input.setPosition (streamPos); in juce_ImageFileFormat.cpp. 

ImageFileFormat* ImageFileFormat::findImageFormatForStream (InputStream& input)
{
    const int64 streamPos = input.getPosition();

    for (ImageFileFormat** i = DefaultImageFormats::get(); *i != nullptr; ++i)
    {
        const bool found = (*i)->canUnderstand (input);

        input.setPosition (streamPos);   // <--------- this line

        if (found)
            return *i;
    }

    return nullptr; 
}

(are these info helpful? ) 

OSX 10.10.4, Xcode 6.4 (6E35b), JUCE from github few days ago.


#4

Apologies for bringing this post back from the grave but I ran into this issue today and have pushed a fix for it to develop.

Ed


#5

Thanks! @ed95, you’re a honest man, you have my admires.

Thank you!