MuseScore icon indicating copy to clipboard operation
MuseScore copied to clipboard

[MU4 Issue] Crash when reopening score after deleting staff where system objects would appear

Open cbjeukendrup opened this issue 1 year ago • 0 comments

To Reproduce Steps to reproduce the behavior:

  1. Create a score from the Symphony orchestra template
  2. Open the "Add/remove instruments" dialog
  3. Remove the strings instruments (violins and everything below) → The violins staff was namely one of the staves where system objects would be shown
  4. Press OK
  5. Save the score → The mscx now contains:
        <SystemObjects>
          <Instance staffId="0" barNumbers="false"/>
          </SystemObjects>
    
  6. Reopen the score → systemObjectStaves now contains a nullptr; see Read400::readScore400, especially the lines:
    • int staffIdx = e.attribute("staffId").toInt() - 1; and sysStaves.push_back(staffIdx);, which puts a -1 in sysStaves
    • for (int idx : sysStaves) { score->addSystemObjectStaff(score->staff(idx)); }, which tries to get the staff at index -1, which returns nullptr
  7. Save the score again → Crash; see Score::write, from the line if (!systemObjectStaves.empty()) {

cbjeukendrup avatar Dec 21 '22 13:12 cbjeukendrup