Keep a late sidecar off the next photograph

A stored edit that arrived after the view had stepped on was applied to
whatever session was open by then — the next photograph's. The wait now
stops once the open it belongs to is no longer the current one.
This commit is contained in:
2026-10-02 20:44:43 -04:00
parent 825c5af20a
commit 379dd1afcc
2 changed files with 46 additions and 36 deletions
File diff suppressed because one or more lines are too long
+10
View File
@@ -805,12 +805,16 @@ pub(crate) fn refresh_export_label(window: &AppWindow) {
///
/// A late arrival redraws, so the image is correct either way; the only
/// difference is whether it was ever briefly shown at its defaults.
///
/// `still_current` is false once the view has moved to another photograph,
/// whose session this sidecar must not be applied to.
fn apply_when_ready(
window: &AppWindow,
rx: Rc<std::sync::mpsc::Receiver<Option<dr_pipeline::Sidecar>>>,
session: &Rc<RefCell<Option<DevelopSession>>>,
rows: &Rc<slint::VecModel<ParamRow>>,
redraw: &Rc<dyn Fn(&AppWindow)>,
still_current: impl Fn() -> bool + 'static,
) {
// Already here — the overwhelmingly common case.
if let Ok(got) = rx.try_recv() {
@@ -830,6 +834,10 @@ fn apply_when_ready(
slint::TimerMode::Repeated,
std::time::Duration::from_millis(50),
move || {
if !still_current() {
held.stop();
return;
}
let Ok(got) = rx.try_recv() else { return };
held.stop();
let Some(w) = weak.upgrade() else { return };
@@ -2858,12 +2866,14 @@ fn wire_remote_open(
// practice it has; `apply_when_ready`
// covers the case where it has not rather
// than blocking the UI thread on a socket.
let still = current.clone();
apply_when_ready(
&w,
sidecar_rx.clone(),
&session,
&rows,
&redraw,
move || still.get() == mine,
);
// TRACES: FR-UI-4
// Under the same magnifier as the last