forge
Explore
Log in

Don't you dare go Hollow

Caption flag resets match the engine's reseek exactly

Browse files at this commit

cda6d0eb7cda9bbff1487112cb7cf3e068d4e44bAhmet Kaan GümüşParent: 25855e8
  • fix
    • caption flag resets match the engine's reseek exactly
Show full message
🐛 fix(timeline): caption flag resets match the engine's reseek exactly

The app gated its grouped-caption drag and trim flag resets on the
caption carrying any link at all, while the engine reseeks only when
the group holds clips: a caption grouped only with another caption
(ctrl-click two captions, Group) latched the seek wait with no frame
ever delivered -- an unbounded repaint loop while paused.

PlaybackSession::caption_grouped_with_clips is now the one public
answer, asked before the edit moves indices, and both reset gates read
it: drag from the press's lane and live index, trim from the trim's
own lane and index. The two sides can no longer disagree.
crates/app/src/player/timeline_edit.rsmodified+23 -8
@@ -455,6 +455,15 @@ impl Player {
455455 let Some(idx) = self.dragged_sub(drag) else {
456456 return;
457457 };
458+ // Asked before the edit, on the indices the press captured: the
459+ // engine's own grouped-with-clips answer, which is exactly when its
460+ // move reseeks -- a caption grouped only with other captions moves no
461+ // media, and a flag reset without a delivered frame would latch the
462+ // seek wait forever.
463+ let grouped = self
464+ .session
465+ .as_ref()
466+ .is_some_and(|session| session.caption_grouped_with_clips(drag.lane, idx));
458467 let start = self.sub_drop_frame(drag.sub, x).0;
459468 match self
460469 .session
@@ -474,9 +483,9 @@ impl Player {
474483 // A lane holds its captions in start order, so the drop moved the
475484 // mark as well as the box: it is re-read off where the caption
476485 // landed rather than left on the index it had, which after the move
477- // is a neighbour's. A grouped caption dragged its clips with it --
478- // the engine reseeks itself, and this owes the flag reset a clip's
479- // drop pays at the same moment.
486+ // is a neighbour's. A grouped-with-clips caption dragged media with
487+ // it -- the engine reseeks itself, and this owes the flag reset a
488+ // clip's drop pays at the same moment.
480489 Some(Ok(())) => {
481490 let mark = self
482491 .session
@@ -491,7 +500,7 @@ impl Player {
491500 }
492501 None => Selection::new(),
493502 };
494- if drag.sub.link.is_some() {
503+ if grouped {
495504 self.reset_after_reseek();
496505 }
497506 }
@@ -1125,17 +1134,23 @@ impl Player {
11251134 // timeline's rate. An `Ok` is *not* "something changed" -- an edge that
11261135 // stopped at a wall it already stood against is `Ok` with no undo step
11271136 // ([`Project::trim_sub`]) -- so only the refusal is ever said out loud.
1128- // A lone caption's trim moves nothing that plays, and nothing reseeks;
1129- // a grouped one trimmed its clips with it, and owes the same flag
1130- // reset a clip's trim pays.
1137+ // A lone caption's trim -- and one grouped only with other captions --
1138+ // moves nothing that plays and reseeks nothing; a caption grouped with
1139+ // clips trimmed them with it and owes the flag reset a clip's trim
1140+ // pays. The grouped question is asked before the edit moves indices,
1141+ // in the engine's own words, so the two answers can never disagree.
11311142 if trim.lane.kind == LaneKind::Subtitle {
1143+ let grouped = self
1144+ .session
1145+ .as_ref()
1146+ .is_some_and(|session| session.caption_grouped_with_clips(trim.lane, trim.idx));
11321147 let trimmed = self
11331148 .session
11341149 .as_mut()
11351150 .map(|session| session.trim_sub(trim.lane, trim.idx, trim.edge, trim.to));
11361151 match trimmed {
11371152 Some(Err(e)) => self.notify_user(format!("NOT TRIMMED — {e}").into()),
1138- Some(Ok(())) if trim.link.is_some() => self.reset_after_reseek(),
1153+ Some(Ok(())) if grouped => self.reset_after_reseek(),
11391154 _ => {}
11401155 }
11411156 cx.notify();
crates/engine/src/playback.rsmodified+4 -2
@@ -1866,8 +1866,10 @@ impl PlaybackSession {
18661866
18671867 /// Whether the caption at `idx` of `lane` is grouped with clips on other
18681868 /// lanes: the one question every caption edit that can move media has to
1869- // ask first, because the answer is whether the edit owes a reseek.
1870- fn caption_grouped_with_clips(&self, lane: Lane, idx: usize) -> bool {
1869+ /// ask first, because the answer is whether the edit owes a reseek -- and
1870+ /// the front-end owes the same answer, asked before the edit moves the
1871+ /// indices, so its flag reset matches the engine's reseek exactly.
1872+ pub fn caption_grouped_with_clips(&self, lane: Lane, idx: usize) -> bool {
18711873 self.project
18721874 .sub_lane(lane)
18731875 .get(idx)