From 02a75ead50a8d49451cdf8e35c3ec27f2a03e9df Mon Sep 17 00:00:00 2001 From: ramox81 <184937705+ramox81@users.noreply.github.com> Date: Fri, 18 Sep 2026 20:36:08 +0300 Subject: [PATCH] Refuse an automation capture while the window is minimized A minimized window has a 0x0 surface; the renderer's screenshot path panicked on the empty read-back buffer and took the whole application down. The capture op now checks the window size first and answers with an error instead of requesting the screenshot. Co-Authored-By: Claude Fable 5.1 --- src/app/control/mod.rs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/app/control/mod.rs b/src/app/control/mod.rs index ecb1d3271..b96183f30 100644 --- a/src/app/control/mod.rs +++ b/src/app/control/mod.rs @@ -866,8 +866,17 @@ impl OpenCADStudio { .main_window .ok_or_else(|| failure("gui_required", "Capture requires a GUI window"))?; let path = string(req, "path")?.to_owned(); - iced::window::screenshot(window) - .map(move |s| Message::ControlScreenshot(path.clone(), Some(s))) + // A minimized window has a 0x0 surface and the renderer + // panics reading it back, so report instead of capturing. + iced::window::size(window).then(move |size| { + let path = path.clone(); + if size.width <= 0.0 || size.height <= 0.0 { + Task::done(Message::ControlScreenshot(path, None)) + } else { + iced::window::screenshot(window) + .map(move |s| Message::ControlScreenshot(path.clone(), Some(s))) + } + }) } "stop" => { self.control.enabled = false; @@ -1062,7 +1071,8 @@ impl OpenCADStudio { screenshot: Option, ) { let result = (|| -> Result { - let s = screenshot.ok_or("Renderer did not return an image")?; + let s = screenshot + .ok_or("The window is minimized or has no size; restore it and capture again")?; let requested_scope = self .control .pending