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

Gsoc 2020: prepare for changes to mmrests and fix #306192 #6108

Closed

Conversation

IsaacWeiss
Copy link
Contributor

@IsaacWeiss IsaacWeiss commented May 22, 2020

This PR adds no new functionality and introduces no bugs,* but simply lays the groundwork so future larger changes will be easier, in keeping with the incremental process recommended in today's GSoC conference call. The upcoming changes are described in my GSoC introductory blog post: https://musescore.org/en/user/101731/blog/2020/05/17/gsoc-2020-week-2-bc-coding-repeats-rests-and-counting-overview.

  • Extract multimeasure rests to new class and ElementType
  • Rename local variables and add comments in Score::createMMRest()
  • Add new Style page for mmrest options

In passing, this also fixes https://musescore.org/en/node/306192.

  • I signed CLA
  • I made sure the code in the PR follows the coding rules
  • I made sure the code compiles on my machine
  • I made sure there are no unnecessary changes in the code
  • I made sure the title of the PR reflects the core meaning of the issue you are solving
  • I made sure the commit message(s) contain a description and answer the question "Why do those changes fix that particular issue?" or "Why are those changes really necessary as improvements?"
  • I made sure the commit message title starts with "fix #424242:" if there is a related issue
  • I created the test (mtest, vtest, script test) to verify the changes I made (TODO)

*Of course, I cannot guarantee this, but I think it's safe.

@IsaacWeiss IsaacWeiss changed the title Gsoc 2020 mmrest class Gsoc 2020: prepare for changes to mmrests May 22, 2020
//---------------------------------------------------------

void Score::createMMRest(Measure* m, Measure* lm, const Fraction& len)
void Score::createMMRest(Measure* firstMeasure, Measure* lastMeasure, const Fraction& len)
Copy link
Contributor

Choose a reason for hiding this comment

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

Yes thanks for verbosity! At least as useful as comments!

painter->setPen(pen);
qreal x1 = pw * .5;
qreal x2 = _mmWidth - x1;
if (_mmRestNumberPos > 0.7 && _mmRestNumberPos < 3.3) { // hack for when number encounters horizontal line
Copy link
Contributor

@ecstrema ecstrema May 23, 2020

Choose a reason for hiding this comment

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

This will cause conflict with PR #6105.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, if yours is merged first I will rebase.

libmscore/style.cpp Outdated Show resolved Hide resolved
@Jojo-Schmitz
Copy link
Contributor

Jojo-Schmitz commented May 23, 2020

Most probably needs PR #6103 being merged into master to pass the mtests on Travis.
But a simple restart of the build should show whether there a more and additional issues.

Not sure though what the vtest fails are about, @AntonioBL? Shouldn't this have been fixed with PR #6092? Or is that missing on master currently?

@AntonioBL
Copy link
Contributor

Actually, vtest script seems to be working properly.
The problem is that, as soon as vtests start, mscore hits an assert:

convert <../mmrest-1.mscx>...
libmscore/scoreElement.h:unknown:
ASSERT: "!e || e->isMMRest()" in file libmscore/scoreElement.h, line 457

@Jojo-Schmitz
Copy link
Contributor

Ah! So a real issue with the code.

@IsaacWeiss
Copy link
Contributor Author

I guess it's file compatibility. I should have known I couldn't leave that for the end.

@Jojo-Schmitz
Copy link
Contributor

Jojo-Schmitz commented May 24, 2020

Failures in mtests that are due to this PR, all but the guitar pro ones

@Jojo-Schmitz
Copy link
Contributor

If you rebase now you'll see your mtest fails only, the guitar pro ones are fixed now

@IsaacWeiss
Copy link
Contributor Author

Why is it erroring now? I'm not seeing what's different in the vest artifact.

@Jojo-Schmitz
Copy link
Contributor

Jojo-Schmitz commented May 27, 2020

@IsaacWeiss IsaacWeiss force-pushed the gsoc-2020-mmrest-class branch 4 times, most recently from 24ffbd7 to 31e43cb Compare May 28, 2020 20:39
@mattmcclinch
Copy link
Contributor

mtest/scripting/p1.log.ref needs to be updated to account for the change in the numerical value of ElementType::CHORD due to the addition of ElementType::MMREST. So wherever it says Chord (92) it should now say Chord (93). Also, I am thinking that isRest() should maybe be redefined to return true for both ElementType::REST and ElementType::MMREST, since up until now it has always returned true for multimeasure rests. This is causing problems with selection and navigation, and it is the reason for the failure of the mmrest-copy test. The other way to fix it, of course, is to make sure you always test for both isRest() and isMMRest(). This is what you have done in many places, but you have missed a few at least.

@MarcSabatella
Copy link
Contributor

In general, any time one changes the class structure, one has to go through the source to find places where there are explicit tests against the old types and see what needs updating.

Since presumably the old isRest(0 tests were retuning true for mmrests too, one solution is to just redefine it accordingly now. Make it explicitly return true for either a rest or an mmrest. Or, define a new isRestType() that returns true for either, and change all existing isRest() calls to this excerpt where it really doesn't make sense.

Regarding the numeric values of the types, it sucks that we rely on specific values anywhere, and potentially there is an opportunity to figure out a way to make the test not depend on that any more. But it's also an opportunity to just move your new type to the end of the list, if that doesn't mess anything up (some things do depend on the actual order).

@IsaacWeiss
Copy link
Contributor Author

IsaacWeiss commented May 31, 2020

@MarcSabatella @mattmcclinch Thank you both very much. I think the right approach is to explicitly check for isMMRest() where necessary, and not mess with redefining isRest() or switching to isRestType(). Otherwise, that would open a whole can of worms: RepeatMeasure is also a child of Rest, and isRest() doesn't currently return true for ElementType::REPEAT_MEASURE. (isChordRest() does, of course, but already in many places a set of checks for only some ChordRest subtypes is preferred.)

@mattmcclinch
Copy link
Contributor

You opened the can of worms when you separated MMRest from Rest. I think that redefining isRest() would help close it back up.

@IsaacWeiss
Copy link
Contributor Author

So is it wrong that isRest() doesn't include RepeatMeasure currently? It seems a bad idea to me to have isRest() include some subtypes but not others. It's been working just fine, and is consistent and logical, having isRest() return true for only ElementType::REST, and having isRepeatMeasure() return true for only ElementType::REPEAT_MEASURE. Sometimes isRest() is called with || isRepeatMeasure() beside it, and sometimes not, so clearly the distinction matters. But maybe it's important to put them back together.

@mattmcclinch
Copy link
Contributor

mattmcclinch commented May 31, 2020

It has caused problems in the past when an element that was known to be a ChordRest and not a Rest was assumed to be a Chord. It is a completely logical assumption, though, since ChordRest only has two direct subclasses, and in almost every other case a concrete element type does not have any subclasses of its own.

@IsaacWeiss
Copy link
Contributor Author

Interesting, thanks. If I make isRest() more inclusive, is there any reason to be concerned about it returning true for a RepeatMeasure in places where it currently doesn't?

@mattmcclinch
Copy link
Contributor

I would be hesitant to make isRest() return true for RepeatMeasure, since currently it does not. RepeatMeasure is weird in that although it is a subclass of Rest, the real-world entity is not any kind of rest at all.

@MarcSabatella
Copy link
Contributor

I see this as an opportunity to clean some of these kinds of things up. That could totally mean changing the class hierarchy so RepeatMeasure is not in fact a subclass of Rest at all, for example. This could perhaps be coordinated with @Kartikay26 's project.

@IsaacWeiss
Copy link
Contributor Author

So I half expected there might be bugs fixed or prevented as a side benefit of distinguishing the classes. I've just come across at least one concrete example where it is problematic for isRest() to return true on mmrests, as it does currently, and my changes unintentionally fixed it: distinguishing the types means you get the right result when trying to enter lyrics on an mmrest, whereas bad things happen in 3.4.2 and 3.5-alpha.

So far, I've gone through about half of the calls to isRest(), and in almost none does it make sense to include mmrests (lots of stuff about laying out dots, for instance). If those wiser than me think it is important to use an isRestType() in those few circumstances, I will.

@IsaacWeiss
Copy link
Contributor Author

"apt-get install failed"? What did I do now?

@mattmcclinch
Copy link
Contributor

mattmcclinch commented Jun 1, 2020

Push again and hope for the best. Sometimes this kind of thing happens, and it has nothing to do with anything you did; it is just Travis being temperamental.

@IsaacWeiss
Copy link
Contributor Author

Woohoo, all checks passed!

@IsaacWeiss IsaacWeiss changed the title Gsoc 2020: prepare for changes to mmrests Gsoc 2020: prepare for changes to mmrests and fix #306192 Jun 1, 2020
@IsaacWeiss
Copy link
Contributor Author

Changed commit message to reference fixing https://musescore.org/en/node/306192. Should be ready to merge.

libmscore/edit.cpp Outdated Show resolved Hide resolved
mscore/editstyle.ui Outdated Show resolved Hide resolved
@IsaacWeiss
Copy link
Contributor Author

Not going to try implementing the mmrest Inspector again yet. I may adjust my project schedule to try learning QML towards the end, but if not, multimeasure rests are just one among the other elements that don't have Inspectors yet.

Add class MMRest and ElementType::MMREST (fix #306192: Lyrics entry with multimeasure rest selected)
Add new Style page
Rename local variables and add comments in createMMRest()
@mattmcclinch
Copy link
Contributor

You are going to want to fetch the latest changes to the master branch and rebase. There should not be any conflicts, but that should allow the checks to pass. As for the inspector, you might want to take a look at mattmcclinch@b956c5f. There is currently no glyph for multimeasure rests in the icon font, so I have it show a question mark for now.

@IsaacWeiss
Copy link
Contributor Author

@mattmcclinch, you are a superhero. And you're just another volunteer?

@mattmcclinch
Copy link
Contributor

Yup, just another volunteer. And I am only too happy to help.

@IsaacWeiss
Copy link
Contributor Author

Superseded by the much more complete #6161.

@IsaacWeiss IsaacWeiss closed this Jun 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants