Copy-paste tied notes included in linked staves in a score with parts leads to crash

• Apr 25, 2019 - 13:21
Reported version
3.0
Type
Functional
Frequency
Once
Severity
S2 - Critical
Reproducibility
Always
Status
closed
Regression
Yes
Workaround
No
Project

Version 3.1 and current nightly/ Windows10

1) New score for 2 Guitar + Tablature template (Tablature, or second linked standard staff as in the test file - see below - no matter)
2) Add two tied whole note in the first linked staves
3) Generate parts (New all -> Ok)
(The test file at this step: test linked ties parts.mscz)
4) Copy staves 1+2 -> Paste in staff 3

Result: crash

  • Other scenarios depending the selection.
    -Crash with:
    Copy staff 1 -> Paste in staff 4
    Copy staff 2 -> Paste in staff4
    -But works if:
    Copy Staff 1, or 2, -> Paste in staff 3

Staff 4 seems to be the "weakest link"


Comments

The crash happens here, while trying to dereference c1, which turns out to be NULL. This is because this function call returns 0 here. It is a bit disturbing that l.isEmpty() should evaluate to true at this point, but let’s set that aside for a second. If we replace

            if (l.isEmpty())
                  return 0;

with

            if (l.isEmpty()) {
                  for (ScoreElement* ee : c->linkList()) {
                        Chord* ch = toChord(ee);
                        if (ch->staff() == nstaff)
                              return ch;
                        }
                  return nullptr;
                  }

the crash is prevented, and the paste succeeds.

Now, why did this line return an empty list? Well, it turns out that even though e.tracks() is updated every time a <Tracklist> tag is encountered, it doesn’t have any effect on the Excerpt’s tracks() map. If this line is moved down two lines so that it comes after s->read(e);
then the Excerpt’s tracks() map will be assigned properly upon load. But any existing scores that have been saved after being read with the buggy version of Score::read() will have already lost all of their <Tracklist> tags.

Fix version
3.1.0