mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-10-24 09:46:59 -06:00
Merge pull request #3762 from Silvertree2010/fix/3590-audit-dxf-import-hatch-source-ha
Stop DXF hatch source-handle loop at first missing handle
This commit is contained in:
@@ -536,7 +536,9 @@ fn boundary(c: &mut Cursor<'_, '_>) -> Option<BezPath> {
|
||||
// The boundary objects it was made from.
|
||||
if let Some(n) = c.count(97) {
|
||||
for _ in 0..n {
|
||||
c.opt(330);
|
||||
if c.opt(330).is_none() {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
Some(bp)
|
||||
|
||||
@@ -380,6 +380,27 @@ fn solid_hatches_fill_and_pattern_hatches_outline() {
|
||||
assert!(square.appearance.fill().is_some_and(|f| !f.paint.is_none()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn hatch_declaring_many_absent_source_handles_parses_quickly() {
|
||||
let base = hatch("1");
|
||||
let at = |code: i32, from: usize| from + base[from..].iter().position(|p| p.0 == code).unwrap();
|
||||
let first = at(92, 0);
|
||||
let end = at(97, first) + 1;
|
||||
let mut boundary = base[first..end].to_vec();
|
||||
*boundary.last_mut().unwrap() = (97, "10000000");
|
||||
let n = 300;
|
||||
let mut e: Vec<(i32, &'static str)> = base[..first].to_vec();
|
||||
e[at(91, 0)] = (91, "300");
|
||||
for _ in 0..n {
|
||||
e.extend_from_slice(&boundary);
|
||||
}
|
||||
e.extend_from_slice(&base[end..]);
|
||||
let start = std::time::Instant::now();
|
||||
let r = open(&entities(&e), &points());
|
||||
assert!(start.elapsed() < std::time::Duration::from_millis(400), "took {:?}", start.elapsed());
|
||||
assert_eq!(r.document.layers[0].children().unwrap().len(), 1, "{:?}", r.warnings);
|
||||
}
|
||||
|
||||
/// A solid hatch: a loop of a line and a spline edge (`fit` its fit data, if any), followed by
|
||||
/// `source` (the loop's source-object count and handles), and a square hole.
|
||||
fn spline_edged_hatch(fit: &[(i32, &'static str)], source: &[(i32, &'static str)]) -> Vec<(i32, &'static str)> {
|
||||
|
||||
Reference in New Issue
Block a user