Merge pull request #383 from KevinGriffin-new/fix/pdf-export

Never fail silently on PDF export; add EXPORTPDF <path> (#369).

The export flow handed off to an async rfd save dialog and mapped a None
result straight to Task::none(). On Linux None also means the dialog never
opened (broken XDG portal / missing zenity), and rfd reports that only via
log, so PDF export could end in total silence. The dialog-None arms now
print a message pointing at EXPORTPDF <path>, and EXPORT/EXPORTPDF take an
optional path that exports straight to a file with no dialog — the
workaround where the native dialog can't open, and a headless entry point.

Conflict: the fix (display.rs, file.rs, mod.rs, COMMANDS.md) auto-merged;
only the additive test block in automation.rs conflicted. Resolved by
keeping main's tests and adding the two #369 tests.

# Conflicts:
#	src/app/automation.rs
This commit is contained in:
Hakan Seven committed 2026-07-16 11:52:46 +03:00
commit 5b4a6719aa
5 files changed
+116 -11

No files matched your search

+10 -5
View File
@@ -1148,7 +1148,10 @@ pub(super) fn on_open_file(&mut self) -> Task<Message> {
}
}
pub(super) fn on_plot_export_path_some(&mut self, path: std::path::PathBuf) -> Task<Message> {
pub(in crate::app) fn on_plot_export_path_some(
&mut self,
path: std::path::PathBuf,
) -> Task<Message> {
let i = self.active_tab;
let scene = &self.tabs[i].scene;
let wires = scene.entity_wires();
@@ -1251,10 +1254,12 @@ pub(super) fn on_open_file(&mut self) -> Task<Message> {
&path,
self.active_plot_style.as_ref(),
) {
Ok(()) => self.command_line.push_info(&format!(
"Exported: {}",
path.file_name().unwrap_or_default().to_string_lossy()
)),
// Full path, not just the file name — when the export was
// driven by EXPORTPDF <path> the user needs to see where
// the file actually landed. (#369)
Ok(()) => self
.command_line
.push_info(&format!("Exported: {}", path.display())),
Err(e) => self.command_line.push_error(&format!("Export failed: {e}")),
}
Task::none()
+20 -2
View File
@@ -3582,7 +3582,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) => {
@@ -3606,7 +3617,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 ───────────────────────────────────────