mirror of
https://github.com/storytold/photocraft.git
synced 2026-12-02 06:20:48 +01:00
Print: restore the winsafe dependency, the DLL check and its tests lost in merges (#5884)
The merges from main dropped three parts of 86f6199b:
- `winsafe` from crates/engine/Cargo.toml (Cargo.lock still listed it, so every
`--locked` CI step failed). It now sits in the engine's existing `cfg(windows)`
dependency table next to `same-file`.
- the `require_windows_pdf()` call. Main moved `craft_print::submit` into
`spool_job`, so the check now runs there, right before the Windows spooler
route; that is the only call that reaches winprint's `WinPdfPrinter`
(Windows.Data.Pdf.dll). The native RGB route, IPP, the app spooler and
Save as PDF don't need the DLL and are unchanged.
- the Windows load test and the no-op test for other platforms.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
ac5611bc80
commit
eeeeb13f0e
3 files changed
+30
No files matched your search
@@ -47,6 +47,9 @@ tempfile = "3"
|
||||
# file is that file (std's `MetadataExt::file_index` is unstable).
|
||||
[target.'cfg(windows)'.dependencies]
|
||||
same-file = "1"
|
||||
# `file.print` loads Windows.Data.Pdf.dll before calling into it (#5884): the safe binding
|
||||
# ui-egui and craft-print already use, pinned to the same version.
|
||||
winsafe = { version = "=0.0.29", default-features = false, features = ["kernel"] }
|
||||
|
||||
# Printing on Unix: an IPP client for CUPS (pure Rust); the web build cannot print.
|
||||
[target.'cfg(all(not(target_arch = "wasm32"), not(target_os = "windows")))'.dependencies]
|
||||
|
||||
@@ -90,6 +90,7 @@ fn spool_job(spooler: Option<&Spooler>, job: &PrintJob, lp: &craft_print::Job) -
|
||||
return app(sp);
|
||||
}
|
||||
if let Some(name) = system_spooler() {
|
||||
require_windows_pdf()?;
|
||||
return craft_print::submit(&job.pdf, lp).map(|m| (m, name.to_string())).map_err(other);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -772,3 +772,29 @@ mod cups {
|
||||
assert_eq!(jobs, 2, "both prints reached the fake CUPS");
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
#[test]
|
||||
fn windows_pdf_component_is_detected_by_loading_its_dll() {
|
||||
// #5884: a Windows image without a loadable Windows.Data.Pdf.dll reports an error instead of
|
||||
// aborting at the delay-load stub.
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let dll = windows_pdf_dll(dir.path());
|
||||
assert!(!windows_pdf_loads(&dll));
|
||||
// Present but not loadable counts as missing.
|
||||
std::fs::create_dir(dir.path().join("System32")).unwrap();
|
||||
std::fs::write(&dll, b"MZ").unwrap();
|
||||
assert!(!windows_pdf_loads(&dll));
|
||||
let root = std::env::var_os("SystemRoot").unwrap();
|
||||
let system = windows_pdf_dll(std::path::Path::new(&root));
|
||||
if system.is_file() {
|
||||
assert!(windows_pdf_loads(&system));
|
||||
assert!(require_windows_pdf().is_ok());
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
#[test]
|
||||
fn the_windows_pdf_check_is_a_no_op_elsewhere() {
|
||||
assert!(require_windows_pdf().is_ok());
|
||||
}
|
||||
Reference in new issue
Block a user