fix(plot): never fail silently on PDF export; add EXPORTPDF <path> (#369)
Export to PDF could end in complete silence: the flow hands off to an async rfd save dialog, and when that future resolves to None the app mapped it straight to Task::none(). None does not only mean the user cancelled — on Linux the XDG portal SaveFile call can fail outright (rfd then tries a zenity fallback, which may not be installed) and the future still just resolves to None. rfd reports those failures only through the `log` crate, and logging is opt-in (--log / RUST_LOG), so the reporter saw exactly what #369 describes: no dialog, no error, no console output, no file. - EXPORT / EXPORTPDF now accept an optional path argument that exports straight to the file with no dialog — both the workaround for systems where the native save dialog cannot open and a headless-testable entry point. A relative path lands next to the drawing; a missing extension gets .pdf. - The dialog-None arms (PlotExportPath / PlotWindowExportPath) now push a command-line message pointing at EXPORTPDF <path> instead of doing nothing. - The success message prints the full output path, not just the file name, so users can find the PDF. Verified end to end on the real binary via --serve: LINE + CIRCLE then EXPORTPDF <path> writes a valid PDF with the expected geometry. Both new tests fail on the previous code. Fixes #369 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
4bcf5063e9
commit
d2af4c0b34
5 changed files with 116 additions and 11 deletions
|
|
@ -3535,7 +3535,18 @@ impl OpenCADStudio {
|
|||
Message::PlotExportPath,
|
||||
)
|
||||
}
|
||||
Message::PlotExportPath(None) => Task::none(),
|
||||
// None means the save dialog was cancelled — or never opened at
|
||||
// all (a broken XDG portal / missing zenity on Linux resolves to
|
||||
// None too, and rfd only reports that through `log`, which is
|
||||
// opt-in). Either way say something instead of silently doing
|
||||
// nothing. (#369)
|
||||
Message::PlotExportPath(None) => {
|
||||
self.command_line.push_info(
|
||||
"PDF export canceled — no file chosen. \
|
||||
If no dialog appeared, use EXPORTPDF <path>.",
|
||||
);
|
||||
Task::none()
|
||||
}
|
||||
Message::PlotExportPath(Some(path)) => self.on_plot_export_path_some(path),
|
||||
|
||||
Message::PlotFormat(f) => {
|
||||
|
|
@ -3559,7 +3570,14 @@ impl OpenCADStudio {
|
|||
Message::PlotWindowExportPath,
|
||||
)
|
||||
}
|
||||
Message::PlotWindowExportPath(None) => Task::none(),
|
||||
// Same silent-None trap as PlotExportPath above. (#369)
|
||||
Message::PlotWindowExportPath(None) => {
|
||||
self.command_line.push_info(
|
||||
"PDF export canceled — no file chosen. \
|
||||
If no dialog appeared, use EXPORTPDF <path>.",
|
||||
);
|
||||
Task::none()
|
||||
}
|
||||
Message::PlotWindowExportPath(Some(path)) => self.on_plot_window_export_path_some(path),
|
||||
|
||||
// ── Print to system printer ───────────────────────────────────────
|
||||
|
|
|
|||
Loading…
Reference in a new issue