From: Ian Jackson Date: Sat, 30 Apr 2022 12:24:21 +0000 (+0100) Subject: fastsplit: Correct z order X-Git-Tag: otter-1.1.0~394 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=08ea86c8e6415e12c15e71e30ee6fe3432f2efcd;p=otter.git fastsplit: Correct z order This was back to front. Signed-off-by: Ian Jackson --- diff --git a/src/fastsplit.rs b/src/fastsplit.rs index bab779ac..37d6ff14 100644 --- a/src/fastsplit.rs +++ b/src/fastsplit.rs @@ -109,11 +109,17 @@ impl InstanceGuard<'_> { ig.ifastsplits.table.get(fsid) })().ok_or_else(|| internal_logic_error("fastsplit on non-fastsplit"))?; + // The new piece (the change, which stays in place) inherits the + // old piece's Z (but we need to give it a new generation so that + // we don't risk having two pieces with the precise same Z). The + // old piece becomes the amount taken and gets the specified Z. + let n_zlevel = ZLevel { z: tgpc.zlevel.z.clone(), zg: ig.gs.gen }; + let mut ngpc = GPiece { pos: tgpc.pos, face: tgpc.face, held: None, - zlevel: tgpc.zlevel.clone() /* placeholder, overwritten below */, + zlevel: n_zlevel, pinned: tgpc.pinned, occult: default(), angle: tgpc.angle, @@ -126,7 +132,6 @@ impl InstanceGuard<'_> { rotateable: tgpc.rotateable, fastsplit: tgpc.fastsplit, }; - new_z.implement(&mut ngpc); let tipc_p = (||{ let p = tipc.p.show(show); @@ -141,6 +146,11 @@ impl InstanceGuard<'_> { &mut ngpc )?; + // Committing. + + // This is outside the infallible closure because borrowck + // can't see that we drop tgpc before doing stuff with ig. + new_z.implement(tgpc); (||{ let nipc = IFastSplits::make_ipc(&mut ig.ioccults.ilks, fs_record.ipc.clone());