FileBasedDocument - feature request

Hi Jules,

Can I please make a feature request?

I’d like a new virtual method in FileBasedDocument, that I can use to suppress the Error Alert
being displayed in certain circumstances. I’ve already had to patch Juce to cater for this case.

The code would look like this:

// MPC Begin
// Default is always "true", i.e. show the alert dialog.
// The app can override this behaviour where required.
virtual bool canWeShowTheFileSaveErrorDialog(const Result &result)
{
  return true;
}
// MPC End

...

FileBasedDocument::SaveResult FileBasedDocument::saveAs (...
{
    if (showMessageOnFailure)
    {
      // MPC Begin
      if (canWeShowTheFileSaveErrorDialog(result) == false)
      {
          // Do NOT show the standard Juce file save error alert!
      }
      else 
      // MPC End
      {
          AlertWindow::showMessageBox (AlertWindow::WarningIcon,
                                     TRANS("Error writing to file..."),
                                     TRANS("An error occurred while trying to save \"DCNM\" to the file: FLNM")
                                     .replace ("DCNM", getDocumentTitle())
                                     .replace ("FLNM", "\n" + newFile.getFullPathName())
                                     + "\n\n"
                                     + result.getErrorMessage());
        }
    }
}

TIA!

Pete

Good request - yes, can’t see why not!

…ok, just looked at that code, but it already has a method parameter “showMessageOnFailure”… Are you looking at an old version of it?

Hi Jules!

To cut a long story short, the latest Jules works fine with this flag - so I’ve been able to get my code working with Juce in this area without needing to change the Juce code at all. :slight_smile:

Many thanks,

Pete