Skip to content

Fix clip and label movement - #12097

Merged
grliszas14 merged 14 commits into
audacity:masterfrom
kryksyh:clip-drag-keep-effects
Sep 18, 2026
Merged

grliszas14 merged 14 commits into
audacity:masterfrom
kryksyh:clip-drag-keep-effects

Conversation

@kryksyh

@kryksyh kryksyh commented Sep 9, 2026 •

Copy link
Copy Markdown
Member

Resolves: multiple item drag issues and crashes

Previously, when a clip moved from one track to another, we changed the track content on the fly.

  • Move a clip from A to B: a new temporary tracklist is created (with full effect stack)
  • In that copy, remove the clip from A and insert it into B
  • Replace affected tracks from the temporary tracklist to the project tracklist
  • Move the clip from B to C: the process repeats

This made the visualization easier - the view model always rendered the current project state.
But it involved too many moving parts and changing the project data model.

This PR changes the process to this:

  • Start dragging - the original clip is hidden, in its place, we create a ghost clip
  • The ghost clip is not a real clip, it does not belong to the project, and the QML item for its rendering refers to the original clip key
  • When dragging across tracks, we move the ghost clip but never change the project data
  • On drag finish, we do the clip movement once as described above

Issues this PR fixes (only ones that I logged during testing)

  • - Slow clip dragging across tracks when source track contain many realtime effects
  • - Slow undo/redo in projects with many realtime effects
  • - Crashes when moving labels with the keyboard
  • - Labels get stuck when dragging with the mouse
  • - Can't drag a clip if scrolled vertically too much, the clip vanishes
  • - During keyboard movement focused track changed to the first track contained moving clip, when moving multiple clips on different tracks
  • - Selection was not restored on drag cancel
  • - Unnecessary undo entries after keyboard move, if a clip didnt move, ie move clip up and then back down
  • - When moving clips and lables together, the selection on labels is reset
  • - History item named "Move clip" when moving clip and label, by dragging a clip
  • - When moving a label no history entry is created
  • - When moving clips and labels together, when drag started from the label, the relative time between clips and labels is not maintained. str: label starts at t:4, clip at t:2. Select both, start moving to the left by the label, observe what's happen when clip touches t:0
  • - When doing clips and labels movement, and mixdown dialog cancelled, labels are still moved, and undo entry is created, and the label selection is reset
  • - Crashes when zooming in or out with offscreen clips caused invalid data offset on unsigned overflow
  • I signed CLA
  • The title of the pull request describes an issue it addresses
  • If changes are extensive, then there is a sequence of easily reviewable commits
  • Each commit's message describes its purpose and effects
  • There are no behavior changes unnecessary for the stated purpose of the PR

Recommended:

  • Each commit compiles and runs on my machine without known undesirable changes of behavior

QA:

  • Testflow test cases have been run

@kryksyh
kryksyh force-pushed the clip-drag-keep-effects branch from 72d9721 to dd72641 Compare September 9, 2026 23:30
@coderabbitai

coderabbitai Bot commented Sep 9, 2026 •

Copy link
Copy Markdown

Review Change StackReview Change Stack

Important

Review skipped

We couldn't safely recover the incremental review. No full review was started, and the last reviewed checkpoint was preserved. Retry later, or explicitly request a full review by commenting @coderabbitai full review.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: CHILL

Plan: Advanced

Run ID: a0ee5721-2b4a-43d0-b02c-582c59ad55c7

📥 Commits

Reviewing files that changed from the base of the PR and between 1ffbdef88c8a35fc586996e4fd6b06587b78c6b3 and 70511578e3adc2926a5561fae94a548b5e3b8007.

📒 Files selected for processing (1)
  • src/projectscene/tests/trackitemsmovecontroller_tests.cpp

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

The change adds a centralized controller for pointer and keyboard movement of clips, labels, and tracks. The QML timeline now uses controller-driven previews, drag ghosts, guidelines, and movement requests. Track-edit APIs now coordinate mixed-item moves with rollback and history updates. Realtime effect states are preserved during track replacement, duplication, and undo/redo. Tests cover movement, boundaries, previews, rollback, and effect preservation.

Estimated code review effort: 5 (Critical) | ~120 minutes

Merge Risk: 🟡 Moderate · up to 70511

The change improves clip and label dragging, but edge cases can still create misleading undo entries or corrupt movement offsets when tracks change during a move. Merge readiness is moderate pending fixes or explicit acceptance.

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly summarizes the primary changes to clip and label movement.
Description check ✅ Passed The description provides detailed motivation, implementation context, affected issues, and checklist status. It does not include a direct issue link after “Resolves:” and leaves some template and QA c…

Warning

Linked repositories: Public OSS repositories can only analyze public repositories installed in this organization. No linked repositories were analyzed; skipped musescore/musescore.


Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 4


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: CHILL

Plan: Advanced

Run ID: 0abcd0dc-6c13-4701-9f77-2339605949c1

📥 Commits

Reviewing files that changed from the base of the PR and between 7c66777 and 72d9721328f85ecc96eb95601ddb74eaa1618d6e.

📒 Files selected for processing (58)
  • au3/libraries/au3-realtime-effects/RealtimeEffectList.cpp
  • au3/libraries/au3-realtime-effects/RealtimeEffectList.h
  • au3/libraries/au3-realtime-effects/RealtimeEffectState.cpp
  • au3/libraries/au3-realtime-effects/RealtimeEffectState.h
  • au3/libraries/au3-track/CMakeLists.txt
  • au3/libraries/au3-track/UndoTracks.cpp
  • src/effects/effects_base/internal/abstractviewlauncher.cpp
  • src/effects/effects_base/internal/realtimeeffectservice.cpp
  • src/project/tests/mocks/dummyeffectinstancefactory.h
  • src/projectscene/CMakeLists.txt
  • src/projectscene/internal/projectviewstate.cpp
  • src/projectscene/projectscenemodule.cpp
  • src/projectscene/qml/Audacity/ProjectScene/tracksitemsview/ClipItem.qml
  • src/projectscene/qml/Audacity/ProjectScene/tracksitemsview/LabelItem.qml
  • src/projectscene/qml/Audacity/ProjectScene/tracksitemsview/TrackClipsContainer.qml
  • src/projectscene/qml/Audacity/ProjectScene/tracksitemsview/TrackItemsContainer.qml
  • src/projectscene/qml/Audacity/ProjectScene/tracksitemsview/TrackLabelsContainer.qml
  • src/projectscene/qml/Audacity/ProjectScene/tracksitemsview/TracksItemsView.qml
  • src/projectscene/tests/CMakeLists.txt
  • src/projectscene/tests/trackitemsmovecontroller_tests.cpp
  • src/projectscene/tests/tracklabelslayoutmanager_tests.cpp
  • src/projectscene/view/tracksitemsview/au3/samplespainterutils.cpp
  • src/projectscene/view/tracksitemsview/trackclipslistmodel.cpp
  • src/projectscene/view/tracksitemsview/trackclipslistmodel.h
  • src/projectscene/view/tracksitemsview/trackitemslistmodel.cpp
  • src/projectscene/view/tracksitemsview/trackitemslistmodel.h
  • src/projectscene/view/tracksitemsview/trackitemsmovecontroller.cpp
  • src/projectscene/view/tracksitemsview/trackitemsmovecontroller.h
  • src/projectscene/view/tracksitemsview/tracklabelslayoutmanager.cpp
  • src/projectscene/view/tracksitemsview/tracklabelslistmodel.cpp
  • src/projectscene/view/tracksitemsview/tracklabelslistmodel.h
  • src/projectscene/view/tracksitemsview/viewtrackitem.cpp
  • src/projectscene/view/tracksitemsview/viewtrackitem.h
  • src/trackedit/iclipsinteraction.h
  • src/trackedit/internal/au3/au3clipsinteraction.cpp
  • src/trackedit/internal/au3/au3clipsinteraction.h
  • src/trackedit/internal/au3/au3interactiontypes.h
  • src/trackedit/internal/au3/au3interactionutils.cpp
  • src/trackedit/internal/au3/au3interactionutils.h
  • src/trackedit/internal/au3/au3labelsinteraction.cpp
  • src/trackedit/internal/au3/au3projecthistory.cpp
  • src/trackedit/internal/trackeditactionscontroller.cpp
  • src/trackedit/internal/trackeditactionscontroller.h
  • src/trackedit/internal/trackeditinteraction.cpp
  • src/trackedit/internal/trackeditinteraction.h
  • src/trackedit/internal/trackeditoperationcontroller.cpp
  • src/trackedit/internal/trackeditoperationcontroller.h
  • src/trackedit/internal/tracksviewrequestsservice.cpp
  • src/trackedit/internal/tracksviewrequestsservice.h
  • src/trackedit/itrackeditinteraction.h
  • src/trackedit/itracksviewrequestsservice.h
  • src/trackedit/tests/CMakeLists.txt
  • src/trackedit/tests/au3clipsinteraction_tests.cpp
  • src/trackedit/tests/au3labelsinteractions_tests.cpp
  • src/trackedit/tests/mocks/clipsinteractionmock.h
  • src/trackedit/tests/mocks/trackeditinteractionmock.h
  • src/trackedit/tests/trackeditactionscontroller_tests.cpp
  • src/trackedit/tests/trackeditoperationcontroller_tests.cpp
💤 Files with no reviewable changes (3)
  • src/trackedit/internal/au3/au3interactionutils.h
  • src/trackedit/internal/trackeditactionscontroller.h
  • src/trackedit/internal/au3/au3interactiontypes.h

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.

@kryksyh
kryksyh force-pushed the clip-drag-keep-effects branch 2 times, most recently from 6905702 to 1ffbdef Compare September 10, 2026 08:52
@kryksyh kryksyh changed the title Clip drag keep effects Fix clip and label movement Sep 10, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: CHILL

Plan: Advanced

Run ID: 81622892-ed4d-4898-9157-e8627a22c804

📥 Commits

Reviewing files that changed from the base of the PR and between 690570270b83e18a77fafb16cc80032b5d4e4283 and 1ffbdef88c8a35fc586996e4fd6b06587b78c6b3.

📒 Files selected for processing (7)
  • src/projectscene/qml/Audacity/ProjectScene/tracksitemsview/TracksItemsView.qml
  • src/projectscene/tests/trackitemsmovecontroller_tests.cpp
  • src/projectscene/view/tracksitemsview/trackitemsmovecontroller.cpp
  • src/trackedit/internal/au3/au3projecthistory.cpp
  • src/trackedit/internal/trackeditactionscontroller.cpp
  • src/trackedit/tests/CMakeLists.txt
  • src/trackedit/tests/trackeditactionscontroller_tests.cpp

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.

@kryksyh
kryksyh force-pushed the clip-drag-keep-effects branch from 1ffbdef to 7051157 Compare September 10, 2026 12:08
@grliszas14
grliszas14 self-requested a review September 10, 2026 14:25
@kryksyh kryksyh mentioned this pull request Sep 11, 2026
6 of 7 tasks
@kryksyh kryksyh added this to the Audacity 4.0.1 milestone Sep 16, 2026
@kryksyh kryksyh moved this from Ready For Dev to Ready for QA in [AU4] Release Maintenance Sep 16, 2026
@kryksyh kryksyh moved this from Ready for QA to Code Review in [AU4] Release Maintenance Sep 16, 2026
@ianalarina ianalarina moved this from Code Review to Ready for QA in [AU4] Release Maintenance Sep 17, 2026
@kryksyh
kryksyh force-pushed the clip-drag-keep-effects branch from 1a0e1a2 to 06bab7c Compare September 17, 2026 13:03
@chinakov chinakov moved this from Ready for QA to In QA in [AU4] Release Maintenance Sep 18, 2026
@chinakov chinakov self-assigned this Sep 18, 2026
@chinakov chinakov moved this from In QA to Ready for Merge in [AU4] Release Maintenance Sep 18, 2026
@chinakov

Copy link
Copy Markdown
Contributor

This is done, thank you!

… tracks

Previously when a clip was moved from one track to another, we were changing the actual track content on the fly.
Due to technical specifics, in fact we were merging a temporary track with a single clip and the destination track

- Move a clip from A to B: new temporary tracklist is created (with full effect stack)
- In that copy remove the clip from A and insert into B
- Replace affected tracks from the temporary tracklist to the project tracklist
- Move the clip from B to C: the process repeats

This made the visualisation easier - the view model always rendered the current project state.
But was involving to many moving parts and changing the project data model.

This PR changes the process to this:

- Start dragging - the original clip is hidden, in its place we create a ghost clip
- The ghost clip is not a real clip, it does not belong to the project and the QML item for its rendering refers to the original clip key
- When dragging across tracks we move the ghost clip, but never change the project data
- On drag finish we do the clip movement once as described above
After introducing ghost clips, the move happens in one moveClips call, and at that point selection still points to the previous project state
Now move item is called when the move is complete, intermediate state is handled by the move controller
On move cancel move all items back and correctly restore selection
Label delegate could be destroyed when the label track moves out of viewport
Qt.callLater still calls the function even when the delegate is already gone, so replacing it with Timer
…and out

size_t might be unsigned, we should check the value before converting to size_t, also adds missing return
Previously moving was updating the real project, and the view's horizontal scroll range was adjusted automatically during dragging
Now that the project is not changed, we have to notify the view about ghost item position
@grliszas14
grliszas14 force-pushed the clip-drag-keep-effects branch from 06bab7c to 4b5372a Compare September 18, 2026 16:31
@grliszas14
grliszas14 merged commit b97e322 into audacity:master Sep 18, 2026
10 checks passed
@github-project-automation github-project-automation Bot moved this from Ready for Merge to Done in [AU4] Release Maintenance Sep 18, 2026
@kryksyh
kryksyh deleted the clip-drag-keep-effects branch September 22, 2026 11:49
kryksyh added a commit that referenced this pull request Sep 22, 2026
Fix clip and label movement (#12097)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

No open projects

Development

Successfully merging this pull request may close these issues.

Audacity crash when zooming in on a split clip crashes when zoomed in and playing

4 participants