Crash on chord symbol entry after load of style
Windows 7, GIT commit: 4554f23
1) Save attached style file JazzChordSymbols.ss
2) Create new score
3) Enter a couple of chords: Select first measure rest, Ctrl+K, C, Tab, C7, Esc
4) Style / Load Style
5) Select the style file you just saved
6) Click another measure rest
7) Enter a chord: Ctrl+K, C
Result: crash as soon as you start to enter the chord
I've tracked this down a way but am confused as to why it is happening. I'm doing a brain dump now; hopefully this will be useful to someone, or will allow me to remember what I think I've learned.
When you load the style, a local variable of type Style is created in Score::loadStyle. The style file is loaded into the temporary variable and then this in turn is copied to the score, at which point the local variable is no longer needed. When the local Style variable goes out of scope, its destructor gets called. This in turn calls the ChordList destructor, which destroys the chord list for the style - the same chord list that is now the actual chord list the score. As a result, subsequent attempts to access the chord list will crash.
What I don't get is that the ChordList destructor first checks isDetached() before actually doing anything drastic (like delete the ChordDescriptions in the list). Normally, it seems that the isDetached() check protects against this sort of problem - there are lots of other temporary/local variables of type ChordList that are created and destroyed in normal operation without destroying the actual chord list for the score (eg, via foreach statements that loop through the list). And I know deep copies are used in various places to protect against this as well.
I'm thinking the problem is that the way Score::loadStyle copies the local Style variable to the score is either not tracking the reference, so isDetached() isn't catching on, or else the the copy simply is not deep but needs to do. The copy is done via an undo(new ChangeStyle) which is like magic to me, so I can't tell what is actually happening.
Note:
The style file JazzChordSymbols.mss was generated by creating a new score, going to Style / General / Chord Symbols, and setting Appearance to Jazz. No other changes. The Style / Save Style. So it should contain all default settings (as of 12/17/2013) except for the chord symbol style.
Attachment | Size |
---|---|
JazzChordSymbols.mss | 20.25 KB |
Comments
I can't reproduce the crash on Windows using bd85fd6a56
Can you ?
Well, now the crash happens when I *finish* entering the chord (I typed "C" and that worked, then "Esc" and it crashes). I can see that the chord list has bogus entries in the chord description list and it is trying to dereference one of these. So the behavior is consistent with what I described before - the chord list was destroyed during the load. But I sort of remember that previously, the chord list itself was bogus, and now it's fine but contains bad chord descriptions.
If it still doesn't fail for you, I know a little more about the style code now so I could look into it further.
seems to be fixed with last change to ChordList.
d211d8c775
Automatically closed -- issue fixed for 2 weeks with no activity.