Skip to content

Allow melismas across rests and fix lyrics crashes#34013

Open
ajuncosa wants to merge 9 commits into
musescore:mainfrom
ajuncosa:melisma-under-rest
Open

Allow melismas across rests and fix lyrics crashes#34013
ajuncosa wants to merge 9 commits into
musescore:mainfrom
ajuncosa:melisma-under-rest

Conversation

@ajuncosa

@ajuncosa ajuncosa commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Resolves: #33735
Resolves: #34027
Resolves: #31986

In this PR:

  • Allow melismas across rests

  • Add a parameter to prevent UndoableTransaction::unwind from immediately freeing the text element. This was causing crashes that affected, at least, the creation of empty lyrics and introduction of melismas, rendering them nearly unusable. The crashes were due to:

    1. double frees because the TextBase::endEdit was deferring deletion through deleteLater()
    2. the elements were being referenced in multiple places after the AddElement::cleanup had freed them (during unwind).

    Therefore, the most straightforward solution to avoid changing the current logic seemed to be to make the cleanup optional. There is probably a cleaner and more future-proof solution to this, but at least it solves the crashes for the time being.

  • Fix buggy vertical positioning of lyrics syllables on partial re-layout

  • Drop empty lyrics on file read: our lyrics system assumes there will be no empty lyrics in the mscx file, therefore any pre-existing empty lyrics are deleted through the newly added lyrics path (in TextBase::endEdit), causing later crashes.

    • Note: this situation should not be possible with 5.0 scores, but mscx files generated using previous versions could end up with empty text fields (e.g. when the lyrics contained only line breaks, because they were not escaped into <br/>). So the fix just acts as a sanity check.

@ajuncosa ajuncosa force-pushed the melisma-under-rest branch from 3ee2443 to a030631 Compare June 30, 2026 15:09
@ajuncosa ajuncosa marked this pull request as ready for review June 30, 2026 15:19
@coderabbitai

coderabbitai Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

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
📝 Walkthrough

Walkthrough

A keepRolledBackElements boolean is threaded through UndoableTransaction::unwind, TransactionManager::endTransaction, and Score::endCmd. Rollback now skips cleanup when that flag is set, letting rolled-back elements remain for deferred deletion in TextBase::endEdit. The lyrics empty-text path now triggers relayout through prev->triggerLayout() and score()->update(). Lyrics::adjustPrevious(), NotationInteraction::addMelisma, and segmentsAreAdjacent also update their gating and lookup logic.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant TextBase
  participant Score
  participant TransactionManager
  participant UndoableTransaction
  TextBase->>Score: endCmd(true, false, true)
  Score->>TransactionManager: endTransaction(true, false, true)
  TransactionManager->>UndoableTransaction: unwind(false)
  UndoableTransaction-->>TransactionManager: rollback without cleanup
  TransactionManager-->>Score: return
  Score-->>TextBase: continue deferred deletion
Loading
🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning The description includes issue resolution and a summary, but it omits the required template checklist and several required confirmations. Add the template checklist items and required confirmations for CLA, testing, commit messages, coding rules, and prior attempts.
✅ Passed checks (3 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The melisma scan change and the unwind cleanup parameter directly address #33735 and #34027.
Out of Scope Changes check ✅ Passed The other edits appear to support the melisma and crash fixes, with no clearly unrelated scope added.
Title check ✅ Passed The title clearly summarizes the main feature and crash-fix changes in the PR.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

Review ran into problems

🔥 Problems

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


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@ajuncosa ajuncosa changed the title Allow melismas under rests Allow melismas under rests and fix lyrics crashes Jun 30, 2026
@ajuncosa ajuncosa requested a review from miiizen June 30, 2026 15:56
@Jojo-Schmitz

This comment was marked as resolved.

Jojo-Schmitz added a commit to Jojo-Schmitz/MuseScore that referenced this pull request Jun 30, 2026
Backport of musescore#34013, commit 1

Co-Authored-By: ajuncosa <59970392+ajuncosa@users.noreply.github.com>
Jojo-Schmitz added a commit to Jojo-Schmitz/MuseScore that referenced this pull request Jul 1, 2026
Backport of musescore#34013, commit 1

Co-Authored-By: ajuncosa <59970392+ajuncosa@users.noreply.github.com>
@davidstephengrant

Copy link
Copy Markdown
Contributor

@ajuncosa When closing the input field after creating extenders, the syllable may jump to an incorrect vertical position. This corrects itself upon relayout.

Screen.Recording.2026-07-03.at.11.16.28.mov

Jojo-Schmitz added a commit to Jojo-Schmitz/MuseScore that referenced this pull request Jul 6, 2026
Backport of musescore#34013, commit 1

Co-Authored-By: ajuncosa <59970392+ajuncosa@users.noreply.github.com>
@ajuncosa ajuncosa force-pushed the melisma-under-rest branch 3 times, most recently from 134cc21 to c4cd870 Compare July 7, 2026 16:31
@ajuncosa ajuncosa changed the title Allow melismas under rests and fix lyrics crashes Allow melismas across rests and fix lyrics crashes Jul 7, 2026
coderabbitai[bot]

This comment was marked as resolved.

Jojo-Schmitz added a commit to Jojo-Schmitz/MuseScore that referenced this pull request Jul 8, 2026
Backport of musescore#34013, commit 1

Co-Authored-By: ajuncosa <59970392+ajuncosa@users.noreply.github.com>
@denisfalqueto

Copy link
Copy Markdown

I built this PR locally on Linux (Qt, Debug) and manually tested the lyrics fixes:

Both scenarios that previously reproduced the problems now behave correctly. Thanks for the fix!

@ajuncosa ajuncosa force-pushed the melisma-under-rest branch from c43105b to ff387d5 Compare July 10, 2026 11:11
@mercuree

Copy link
Copy Markdown
Contributor

This PR also partially fixes #31986. The second case with the project file from Musescore 4.6.5 still crashes.

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.

Crash closing empty text input field Melismas under rests Crash if lyrics text is empty or contains line breaks

6 participants