From 0f12ac151fa2e6eaedf3c322feb4eb0d49cff905 Mon Sep 17 00:00:00 2001 From: Korg1ch <57859048+Korg1ch@users.noreply.github.com> Date: Sun, 18 Oct 2026 09:19:41 +0300 Subject: [PATCH] fix(engine): refuse a Content-Aware Fill with nothing to sample instead of filling black (#6532) --- crates/engine/src/edit_menu_cmds.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/crates/engine/src/edit_menu_cmds.rs b/crates/engine/src/edit_menu_cmds.rs index da9a4d0482..8abc4bfd28 100644 --- a/crates/engine/src/edit_menu_cmds.rs +++ b/crates/engine/src/edit_menu_cmds.rs @@ -719,6 +719,13 @@ fn content_aware_fill_as(s: &mut Session, p: &Value, cmd: &'static str, label: & let cancel = || ctx.cancelled(); let plan = content_aware_plan_with(&doc, id, &p, cmd, &photocraft_raster::Interrupt::cancel_only(&cancel))?; let CafPlan { layer, rect, fmt, img, layer_px, cover, hole, source, opts, output, .. } = plan; + // Patches come only from the sampling area outside the fill area. With none (a + // Rectangular `margin` of 0, a Custom area inside the selection or off the canvas) + // the fill would be black (#6532), so refuse instead. The workspace's preview builds + // the same plan and may show an empty area while the Sampling Brush adds to it. + if !source.iter().any(|s| *s) { + return Err(bad(cmd, "nothing to sample from: the sampling area has no pixels outside the fill area")); + } let (w, h) = (rect.width() as usize, rect.height() as usize); let n = fmt.channels(); // The fill changes only the fill area: keep the layer's pixels and the coverage over