LMMS / LMMS/lmms

Ability to undo changes to Song (restore deleted tracks)

Open
#6,348 0 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
C++
Stars
10.4k
Forks
1.3k
Avg merge
2d 13h
Merged PRs (30d)
7

Description

This is essentially a roadmap to undo deletion of tracks.

At the moment trying to restore a checkpoint of Song will result in a crash. That's why we can't undo track deletion and why undo of copy-paste is implemented in such a weird way right now.

I've identified what needs to be done to fix this. In theory it will enable us to undo deleted tracks. In reality the journal system is a terrible solution.

Here are the things that need to be fixed:

  • Usage of PatternTrack::s_infoMap

    • Problem: Using the [ ] operator to lookup map values may add invalid values to the map.
    • Solution: create a correct getter function - makes it more readable too.
  • MidiPortMenu (gui) stored inside MidiPort (core)

    • Background: The InstrumentTrackWindow stores a menu in the Instrument so the TrackOperationsWidget can reuse it.
    • Problem: When the window is deleted it will try to remove the menu from the instrument, but if the instrument has been deleted first it will crash.
    • Solution: don't share the menu, store it locally or create it on-demand.
  • Order of deletion for models and views (optional)

    • Background: Sometimes the view deletes the model, sometimes the model emits a signal that deletes the view.
    • Problem: This is a source of confusion that perhaps led to the two bugs above.
    • Solution: Agree on best approach and clean up code.
  • Optimize undo of Song (optional)

    • Problem: Undoing Song causes the whole project to be reloaded.
    • Hacker's solution: Only reload tracks that have changed.
    • Real solution: Rework the entire codebase to use QUndoCommand

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing PatternTrack::s_infoMap and the MidiPortMenu relationship between MidiPort, InstrumentTrackWindow, Instrument, and TrackOperationsWidget. Review how Song checkpoints are restored and how QUndoCommand is currently used. Done would require resolving the listed crash causes and establishing a clear approach for undoing deleted tracks; the optional cleanup is not defined.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
desktop
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.