fix #280055: chord symbol stays high #4402
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Harmony layout can happen during ChordRest layout (because we need to assign the harmony shape to the chordrest for spacing purposes), but it also happens during the "normal" layout of segment elements later, which handles harmony not attached to a chordrest, and it is also when autoplace happens.
It can be dangerous to layout the harmony unless you know for sure an autoplace will follow, since the layout resets the harmony to default position. That's why just the yesterday I added a check to not layout the harmony it unnecessarily in ChordRest::shape, since there are times when this gets called without a subsequent autoplace (and this isn't the right time to do the autoplace). Yet, it's important that when we finally do the autoplace, theharmony has to have been laid out during this layout operation - otherwise a previously-autoplaced chord can get stuck up high, which is the bug here. We were sometimes skipping the layout before autoplace on the assumption it would was already done in ChordRest::shape, but with my (needed) change yesterday, that's no longer reliably true.
It's harmless to layout twice as long as you know an autoplace follows. So, the fix is to always do the layout before the autoplace, while still being careful not to layout unnecessarily during ChordRest::shape().
@dmitrio95 I wouldn't mind a look from you