Skip to content

Fix Keyframes don't get restored after trim in undo#1794

Closed
bmatherly wants to merge 1 commit intomasterfrom
trim_in_keyframe_restore
Closed

Fix Keyframes don't get restored after trim in undo#1794
bmatherly wants to merge 1 commit intomasterfrom
trim_in_keyframe_restore

Conversation

@bmatherly
Copy link
Copy Markdown
Member

Copy link
Copy Markdown
Member Author

@bmatherly bmatherly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same change is not needed for trim out because we do not delete keyframes beyond the end of a clip when we trim out - so they are still there before an undo opteration.

} else if (m_model.trimClipInValid(trackIndex, clipIndex, delta, ripple || roll)) {
if (!m_undoHelper) {
m_undoHelper.reset(new UndoHelper(m_model));
if (!ripple) {
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing SkipXML for trim in causes the undo helper to create XML to capture the keyframe state.

I notice that the RestoreTracks logic here and in timelinecommands.cpp is inverted. So I made them match.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes an undo regression where trimming a clip could alter filter/link keyframes and those keyframes would not be restored when the trim was undone. This is achieved by ensuring trim-in operations retain enough state (XML) and by explicitly restoring filter/link properties during undo of clip resizes.

Changes:

  • Adjust trim-in undo hinting to avoid skipping XML capture for non-ripple trims and to restore tracks for ripple trims.
  • Enhance UndoHelper::undoChanges() to restore filter and link properties from the pre-change XML when undoing a clip resize/trim.
  • Align TrimClipInCommand hint usage with the updated trim-in behavior.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/docks/timelinedock.cpp Changes trim-in undo helper hints so XML is no longer skipped for non-ripple trim-in, enabling keyframe restoration.
src/commands/undohelper.cpp Restores filter/link properties from stored XML during undo of clip resize to recover keyframes affected by trimming.
src/commands/timelinecommands.cpp Updates TrimClipInCommand to set RestoreTracks for ripple trims.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

info.out_delta,
info.in_delta);
if (!info.xml.isEmpty() && !info.isBlank) {
// Pass all properties for links and filters to restore keyframes that might have been affected by a resize.
m_undoHelper->setHints(UndoHelper::SkipXML);
} else {
if (ripple) {
m_undoHelper->setHints(UndoHelper::RestoreTracks);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is what I was afraid of. The trim methods are called with high frequency while dragging the handles.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #1795

@bmatherly
Copy link
Copy Markdown
Member Author

Superseded by #1795

@bmatherly bmatherly closed this Mar 14, 2026
@bmatherly bmatherly deleted the trim_in_keyframe_restore branch March 14, 2026 14:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants