Fix change frame rate/speed corrupting selected line duration (#11650)#11653
Merged
Conversation
Change frame rate (and change speed) updated each line's start and end time in two separate steps. When times grow (e.g. 25 -> 23.976), setting the start first pushes it past the still-unscaled end, briefly producing start > end / a negative duration that gets published via change notification. For the selected line this transient leaks into the editor's two-way bound time/duration up/down controls: the duration control coerces the negative value to zero and writes it back into the model, moving the end time. The result is the selected line's end time scaled roughly twice, inflating its duration (issue #11650). Non-selected rows have no bound controls, so they scale correctly. Add SubtitleLineViewModel.SetTimes(start, end) which assigns both times with notifications suppressed (the idiom already used by the constructor and UpdateFrom) and recomputes duration once, so no invalid intermediate state is ever exposed. Use it from ChangeFrameRate and ChangeSpeed. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #11650.
Problem
When changing frame rate (e.g. 25 → 23.976), the currently selected line gets a corrupted end time / duration — sometimes by a few seconds, sometimes by minutes/hours. Every other line scales correctly.
In the reporter's screenshots, line 9 (selected) scales its start correctly (
01:05:48,320→01:08:36,950) but its end jumps to01:11:32,782, giving a ~2m55s duration instead of ~1.9s.Root cause
ChangeFrameRate(and the identicalChangeSpeed) updated each line's times in two separate steps — start first, then end:When times grow (ratio > 1), step 1 moves the start past the still-unscaled end, momentarily producing
start > end→ a negative duration, which is published via change notification.That transient is harmless for ordinary rows, but the selected row is live two-way-bound to the editor's time/duration up/down controls. The duration control (
SecondsUpDown) coerces the negative value to zero and writes it back into the model, which firesOnDurationChangedand moves the end time. Interleaved with step 2, the selected line's end ends up scaled roughly twice (4292.78 ≈ 3950.2 × ratio²). Non-selected rows have no bound controls, so they are unaffected.Fix
Add
SubtitleLineViewModel.SetTimes(start, end)which assigns both times with change notifications suppressed (the same idiom already used by the constructor andUpdateFrom) and recomputes duration once — so no invalid intermediate state is ever exposed to the bound controls. Use it from bothChangeFrameRateandChangeSpeed(which had the identical latent bug).Testing
dotnet build src/ui/UI.csprojsucceeds with 0 warnings / 0 errors.🤖 Generated with Claude Code