How to save a file correctly?

gui
#1

I want to save a file(*.txt) to the Specified path of my computer, but it doesn’t work according to the juce example of DialogsDemo. I had changed the path, but when it comes to this function


the error is like this:

I would appriciate it if anyone can tell me why it is wrong. Thanks in anvance.

0 Likes

#2

Your std::unique_ptr<FileChooser> declared at the top of the if scope will go out of scope and be deleted at the closing brace, so the fc->launchAsync() call is going to get the file picked callback on a deleted object. Make fc a member variable so it’s lifetime is correct.

0 Likes

#3

Ok, thank you :slight_smile:

0 Likes