Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #17891: Instrument names follow largest stave spatium in part #19161

Merged
merged 3 commits into from
Oct 26, 2023

Conversation

miiizen
Copy link
Contributor

@miiizen miiizen commented Aug 24, 2023

Resolves: #17891
Resolves: #19577

  • I signed the CLA
  • The title of the PR describes the problem it addresses
  • Each commit's message describes its purpose and effects, and references the issue it resolves
  • If changes are extensive, there is a sequence of easily reviewable commits
  • The code in the PR follows the coding rules
  • There are no unnecessary changes
  • The code compiles and runs on my machine, preferably after each commit individually
  • I created a unit test or vtest to verify the changes I made (if applicable)

@oktophonie oktophonie added the vtests This PR produces approved changes to vtest results label Aug 29, 2023
@@ -64,6 +64,8 @@ class InstrumentName final : public TextBase
SysStaff* sysStaff() const { return _sysStaff; }
void setSysStaff(SysStaff* s) { _sysStaff = s; }

double spatium() const;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This implicitly overrides EngravingItem::spatium(). You should make EngravingItem::spatium() virtual and override it explicitly. This type of solution may not be perfect either, but at least it is more obvious, and you no longer need that cast inside TextFragment::font

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Making EngravingItem::spatium() virtual was my first approach, but after Michele asked me to do a performance test we found that layout took noticeably longer (3-4%). I can change the name of the method to avoid confusion, though we'd keep the cast.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, making spatium() virtual is very elegant codewise, but spatium() is an extremely hot function, and my concern was that resolving the vtable at every call would carry a noticeable runtime cost (which seems to be indeed the case), so I advised against making it virtual. I agree that overriding the method implicitely may cause confusion though, so it's probably better to just call it a different name

Copy link
Contributor

@RomanPudashkin RomanPudashkin Oct 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you are right. We just should rename InstrumentName::spatium()

@RomanPudashkin RomanPudashkin merged commit 43341a3 into musescore:master Oct 26, 2023
10 of 11 checks passed
Jojo-Schmitz pushed a commit to Jojo-Schmitz/MuseScore that referenced this pull request Oct 26, 2023
Jojo-Schmitz pushed a commit to Jojo-Schmitz/MuseScore that referenced this pull request Oct 26, 2023
@miiizen miiizen deleted the 17891-instrument-name-size branch January 9, 2024 15:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
vtests This PR produces approved changes to vtest results
Projects
None yet
4 participants