Skip to content

Commit

Permalink
Correctly handle the jpeg quality dialog being cancelled.
Browse files Browse the repository at this point in the history
Bug: #1322878
  • Loading branch information
cameronwhite committed Feb 21, 2015
1 parent 037c7cf commit 9c601d2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
14 changes: 7 additions & 7 deletions Pinta.Core/ImageFormats/JpegFormat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,16 @@ protected override void DoSave(Pixbuf pb, string fileName, string fileType, Gtk.
//Show the user the JPG export compression quality dialog, with the default
//value being the one loaded in (or the default value if it was not saved).
level = PintaCore.Actions.File.RaiseModifyCompression(level, parent);

if (level == -1)
throw new OperationCanceledException ();
}

if (level != -1)
{
//Store the "previous" JPG compression quality value (before saving with it).
PintaCore.Settings.PutSetting(JpgCompressionQualitySetting, level);
//Store the "previous" JPG compression quality value (before saving with it).
PintaCore.Settings.PutSetting(JpgCompressionQualitySetting, level);

//Save the file.
pb.SavevUtf8(fileName, fileType, new string[] { "quality", null }, new string[] { level.ToString(), null });
}
//Save the file.
pb.SavevUtf8(fileName, fileType, new string[] { "quality", null }, new string[] { level.ToString(), null });
}
}
}
8 changes: 7 additions & 1 deletion Pinta/Actions/File/SaveDocumentImplementationAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,15 @@ private bool SaveFileAs (Document document)

PintaCore.System.LastDialogDirectory = fcd.CurrentFolder;

// If saving the file failed or was cancelled, let the user select
// a different file type.
if (!SaveFile (document, file, format, fcd))
continue;

//The user is saving the Document to a new file, so technically it
//hasn't been saved to its associated file in this session.
document.HasBeenSavedInSession = false;

SaveFile (document, file, format, fcd);
RecentManager.Default.AddFull (fcd.Uri, PintaCore.System.RecentData);
PintaCore.System.ImageFormats.SetDefaultFormat (Path.GetExtension (file));

Expand Down Expand Up @@ -223,6 +227,8 @@ private bool SaveFile (Document document, string file, FormatDescriptor format,
} else {
throw e; // Only catch exceptions we know the reason for
}
} catch (OperationCanceledException) {
return false;
}

document.Filename = Path.GetFileName (file);
Expand Down

0 comments on commit 9c601d2

Please sign in to comment.