Save PDF: OK on Custom… keeps the overprint option it opened with over a preset saved again

When the saved flattener preset was deleted and saved again under the
same name with another Preserve Overprints value while Custom… was open,
OK took the new preset's value instead of the one the dialog showed.
OK now keeps the value the options opened with, and reads the preset
only when that value is missing.
This commit is contained in:
dotCooCoo committed 2026-11-18 16:48:42 -08:00
1 parent e81061dd1e
commit 82edccca6f
2 files changed
+24 -7

No files matched your search

+8 -7
View File
@@ -964,7 +964,11 @@ fn custom_body(_app: &mut VectorcraftApp, ui: &mut egui::Ui, d: &mut Dialog) ->
fn custom_confirm(app: &mut VectorcraftApp, d: &Dialog) -> Result<Value, String> {
let mut o = custom_options(d)?;
let mut parent = super::parent(d).ok_or("the dialog it was opened over is no longer open")?;
let before = flattener(&parent, &app.session.prefs.flattener_presets).ok();
let kept = d
.fields
.get(KEPT_OVERPRINTS)
.and_then(Value::as_bool)
.or_else(|| flattener(&parent, &app.session.prefs.flattener_presets).ok().map(|before| before.preserve_overprints));
let base = match FlattenOptions::find_preset(&flattener_name(&parent), &app.session.prefs.flattener_presets) {
Some(base) => base,
None => {
@@ -974,14 +978,11 @@ fn custom_confirm(app: &mut VectorcraftApp, d: &Dialog) -> Result<Value, String>
};
// The writer sets the first two itself, so they take the preset's values: options that
// otherwise match the preset leave its name showing. The writer keeps overprints only where the
// options and Overprint both keep them, so the options keep the value they had before, or the
// value they opened with when those can no longer be read.
// options and Overprint both keep them, so the options keep the value they opened with, even
// when their preset was deleted, changed or made again under its name meanwhile.
o.clip_complex_regions = base.clip_complex_regions;
o.preserve_alpha = base.preserve_alpha;
o.preserve_overprints = match before {
Some(before) => before.preserve_overprints,
None => d.fields.get(KEPT_OVERPRINTS).and_then(Value::as_bool).unwrap_or(o.preserve_overprints),
};
o.preserve_overprints = kept.unwrap_or(o.preserve_overprints);
if o == base {
parent.fields.remove("flattener");
} else {
@@ -1151,6 +1151,22 @@ fn custom_keeps_the_overprint_option_of_a_saved_preset_deleted_meanwhile() {
}
}
/// OK keeps the overprint option Custom… opened with when its saved preset is deleted and made
/// again under the same name with another overprint option meanwhile.
#[test]
fn custom_keeps_the_overprint_option_it_opened_with_over_a_preset_made_again() {
let (mut app, _, _) = app();
app.run("flattener.presets.save", json!({"name": "Mine", "balance": 20, "preserveOverprints": false})).unwrap();
open_advanced(&mut app, json!({"compatibility": "1.3", "flattenerPreset": "Mine", "advanced": {"overprint": "preserve"}}));
Reader::new().click_custom(&mut app);
assert!(!app.ui.dialog.as_ref().unwrap().bool("preserveOverprints"), "shown as the preset had it");
app.run("flattener.presets.delete", json!({"name": "Mine"})).unwrap();
app.run("flattener.presets.save", json!({"name": "Mine", "balance": 20, "preserveOverprints": true})).unwrap();
super::super::confirm(&mut app).unwrap();
let d = app.ui.dialog.as_ref().unwrap();
assert_eq!(d.fields["flattener"]["preserveOverprints"].as_bool(), Some(false));
}
/// Flattener preset shows a preset named in another case by its name, not as [Custom].
#[test]
fn flattener_preset_shows_a_name_given_in_any_case() {