Skip to content

Conversation

@SKefalidis
Copy link
Contributor

@SKefalidis SKefalidis commented May 2, 2020

Relates to: https://musescore.org/en/node/303422

I removed the _even variable which does not do anything other than creating a bug where there are lyrics that are neither odd nor even (as far as Lyrics::layout is concerned). Even Layout::isEven uses _no instead of _even.

This further breaks the behavior of the program when importing lyrics (since now no lyrics have the correct color when imported), but I would think that it is a step in the right direction :^).

  • 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

@SKefalidis
Copy link
Contributor Author

SKefalidis commented May 2, 2020

As far as the issue is concerned, I see 2 possible solutions. One is removing the call to styleChanged from the Layout method. As far as I can tell, no other class calls styleChanged from its Layout method, and this removal fixes the problem.
Edit: the first possible solution would be a significant regression as @mattmcclinch pointed out.
On the other hand, even with this fix, when the user changes the style of the score, the color of the lyrics gets reset. So the other (probably better solution) is to track down that bug which might solve this too.

@SKefalidis SKefalidis changed the title fix #303422: fixed odd lyrics bug, removed redundant _even variable fixed odd lyrics bug, removed redundant _even variable May 2, 2020
@Jojo-Schmitz
Copy link
Contributor

Jojo-Schmitz commented May 2, 2020

Strange enough Lyrics::isEven() uses _no % 1 whereas Lyrics::propertyDefault() and Lyrics::layout() use _no & 1. Should be the same thing, but the latter might be faster, so you might as well change that too, at least god for consistency.

@SKefalidis
Copy link
Contributor Author

SKefalidis commented May 2, 2020

The travis failure was expected.

@Jojo-Schmitz
Copy link
Contributor

Jojo-Schmitz commented May 2, 2020

I believe that Travis CI mtest failure is exactly what this change is supposed to fix? See https://travis-ci.org/github/musescore/MuseScore/jobs/682247601#L4340-L4362

The travis failure was expected.

Edit: I suspected that ;-)

So this PR does related to an earlier PR of your's, #5910, right?

@SKefalidis
Copy link
Contributor Author

SKefalidis commented May 2, 2020

Yes, it does relate to that PR.
I looked around a bit more and I believe that removing the call to styleChanged is the way to go (I'll test it more and I will upload it). This should fix the related issue.
Also _no % 1 is also a bug if I am not mistaken (it is always equal to 0), so you are right, I'll change that.

@Jojo-Schmitz
Copy link
Contributor

Jojo-Schmitz commented May 2, 2020

Outch, I didn't even notice that it is _no % 1 but read it for _no % 2, which probably was intended there. How could this have ever worked?
Ah, I see, that Lyrics::isEven() is not used anywhere...
Looks like a rather bad thinko or (not quite as bad a) typo from 4944400

Once you fixed Lyrics::isEven(), better use it too in those other places that currently directly work use _no & 1

@mattmcclinch
Copy link
Contributor

The purpose of the _even flag is to determine whether or not the parity of the verse number has changed since the last time Lyrics::layout() was called. initTid() should only be called when the lyric changes from even to odd or vice versa. It certainly should not be called every time the lyric is laid out. The _even flag makes sure that it is only called when necessary. I do not see what removing this flag is supposed to fix.

@SKefalidis
Copy link
Contributor Author

@mattmcclinch that is very interesting and useful (and your valuable information helps explain the regression described above). What it fixed is the inconsistent behavior between odd and even lyrics. It looks like the problem lies somewhere else.

@Jojo-Schmitz
Copy link
Contributor

Jojo-Schmitz commented May 2, 2020

How about setNo(int n) not just setting _no, but also _even?
And also in Lyrics::setProperty() and Lyrics::readProperties().

@SKefalidis
Copy link
Contributor Author

SKefalidis commented May 2, 2020

My guess is that the problem is that all lyrics are initialized using the first constructor (line 5189 of importmxmlpass2, maybe?), therefore the yare all considered odd. Then layout runs and the even ones become even and they lose their properties because of styleChanged.

Edit: Yes, it's most probably that, I'll push a fix soon (hopefully).

@SKefalidis SKefalidis force-pushed the xml-color branch 2 times, most recently from 199facb to a6b45e7 Compare May 2, 2020 14:00
@SKefalidis SKefalidis changed the title fixed odd lyrics bug, removed redundant _even variable fix #303422: lyrics color is preserved when importing mxml + small bugfix and cleanup for isEven May 2, 2020
}
else {
l->setNo(lyricNo);
l->setEven(lyricNo % 2);
Copy link
Contributor

Choose a reason for hiding this comment

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

Really? The % operator?

Copy link
Contributor Author

@SKefalidis SKefalidis May 2, 2020

Choose a reason for hiding this comment

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

I would prefer to do the following l->setEven(l->isEven()) but doesn't that look even more confusing? Either way, hopefully, @Jojo-Schmitz s idea of setting _even inside setNo will work flawlessly. That will alleviate the need for setEven.

Copy link
Contributor

@Jojo-Schmitz Jojo-Schmitz May 2, 2020

Choose a reason for hiding this comment

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

Why not use l->setEven(isEven(lyricsNo))?
Ah, isEven() doesn't take an argument.
But at least use lyricNo & 1
Still better would be when setNo() also sets odd/even

Copy link
Contributor

Choose a reason for hiding this comment

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

I believe that setting _even inside setNo() is a very bad idea. Unless you mean you are going to compare it against its previous value and call initTid() and set styleDidChange to true if the values differed. Probably best to just let this all happen in one place.

Copy link
Contributor Author

@SKefalidis SKefalidis May 2, 2020

Choose a reason for hiding this comment

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

@mattmcclinch yes, that's what I was thinking to do.
Frankly, I don't love either option. I prefer setters than only set, but at the same time having to call a second function when setting the number of the lyric is asking for trouble.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry, what are the two options that you don't love?

Copy link
Contributor Author

@SKefalidis SKefalidis May 2, 2020

Choose a reason for hiding this comment

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

The first one is setting _even in setNo (as you explained it has downsides, and it might even be not feasible). The second one is having to call 2 functions setNo and setEven together.
They are decent, but not quite as clean as I would hope :^).

Copy link
Contributor

@mattmcclinch mattmcclinch May 2, 2020

Choose a reason for hiding this comment

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

Ah, so the second option is what you are currently doing. This is, in my opinion, the correct way to go about this. In most cases, you would only have to call setNo() and not bother calling setEven() (because it wouldn't be the right thing to do), but here is a case where you need to call both.

@SKefalidis
Copy link
Contributor Author

Finally, a solution that seems pretty safe and decent (thank you very much @mattmcclinch). I added a comment that explains the use of _even.

@Jojo-Schmitz I like your idea very much, but at first I would like to test if that breaks something else (like the capella import).

@SKefalidis SKefalidis marked this pull request as draft May 2, 2020 14:07
@SKefalidis SKefalidis changed the title fix #303422: lyrics color is preserved when importing mxml + small bugfix and cleanup for isEven [WIP] fix #303422: lyrics color is preserved when importing mxml + small bugfix and cleanup for isEven May 2, 2020
@SKefalidis SKefalidis force-pushed the xml-color branch 2 times, most recently from 2bbb957 to 82a15b9 Compare May 2, 2020 20:51
@SKefalidis
Copy link
Contributor Author

SKefalidis commented May 2, 2020

Added comments, changed % 2 -> & 1. From what I've gathered this is the only place where we want both setNo and setEven, that's why I will leave them as separate functions. If, in the future, the same problem arises for some other import I believe that the comments will help clarify the solution.

@SKefalidis SKefalidis marked this pull request as ready for review May 2, 2020 21:22
@SKefalidis SKefalidis changed the title [WIP] fix #303422: lyrics color is preserved when importing mxml + small bugfix and cleanup for isEven fix #303422: lyrics color is preserved when importing mxml + small bugfix and cleanup for isEven May 2, 2020

bool styleDidChange = false;
if ((_no & 1) && !_even) {
if (isEven() && !_even) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, now this does look confusing. One would need to look up what isEven() does to find that it does not work on _even, but on '_no'
I know I siggested to use isEven(), but I change my mind in the light of how this looks now ;-)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I feel like the real problem is _even. Should I change it to _wasEven?

Copy link
Contributor

Choose a reason for hiding this comment

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

But then void setEven(bool b) { _even = b; } seems strange

styleDidChange = true;
}
if (!(_no & 1) && _even) {
else if (!isEven() && _even){
Copy link
Contributor

Choose a reason for hiding this comment

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

same here

switch (id) {
case Pid::SUB_STYLE:
return int((_no & 1) ? Tid::LYRICS_EVEN : Tid::LYRICS_ODD);
return int(isEven() ? Tid::LYRICS_EVEN : Tid::LYRICS_ODD);
Copy link
Contributor

Choose a reason for hiding this comment

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

here though it is OK

@SKefalidis
Copy link
Contributor Author

Should I also modify testLyricsColor.xml to cover this case (of multiple colored lines of lyrics)?
(@Jojo-Schmitz )

@Jojo-Schmitz
Copy link
Contributor

Should I also modify testLyricsColor.xml to cover this case (of multiple colored lines of lyrics)?

Yes, I think so

Jojo-Schmitz added a commit to Jojo-Schmitz/MuseScore that referenced this pull request Jul 27, 2021
Up to 3.5 it worked only for first line (number="1"), in 3.6 and master it stopped working all together

Backport of musescore#8033, resp. duplicate of musescore#8034. See also musescore#6021
Jojo-Schmitz added a commit to Jojo-Schmitz/MuseScore that referenced this pull request Jul 27, 2021
Jojo-Schmitz added a commit to Jojo-Schmitz/MuseScore that referenced this pull request Jul 27, 2021
Up to 3.5 it worked only for first line (number="1"), in 3.6 and master it stopped working all together

Backport of musescore#8033, resp. duplicate of musescore#8034. See also musescore#6021
Jojo-Schmitz added a commit to Jojo-Schmitz/MuseScore that referenced this pull request Jul 27, 2021
Jojo-Schmitz added a commit to Jojo-Schmitz/MuseScore that referenced this pull request Jul 28, 2021
Up to 3.5 it worked only for first line (number="1"), in 3.6 and master it stopped working all together

Backport of musescore#8033, resp. duplicate of musescore#8034. See also musescore#6021
Jojo-Schmitz added a commit to Jojo-Schmitz/MuseScore that referenced this pull request Jul 28, 2021
Jojo-Schmitz added a commit to Jojo-Schmitz/MuseScore that referenced this pull request Jul 28, 2021
Up to 3.5 it worked only for first line (number="1"), in 3.6 and master it stopped working all together

Backport of musescore#8033, resp. duplicate of musescore#8034. See also musescore#6021
Jojo-Schmitz added a commit to Jojo-Schmitz/MuseScore that referenced this pull request Jul 28, 2021
Jojo-Schmitz added a commit to Jojo-Schmitz/MuseScore that referenced this pull request Aug 13, 2021
Up to 3.5 it worked only for first line (number="1"), in 3.6 and master it stopped working all together

Backport of musescore#8033, resp. duplicate of musescore#8034. See also musescore#6021
Jojo-Schmitz added a commit to Jojo-Schmitz/MuseScore that referenced this pull request Aug 13, 2021
Jojo-Schmitz added a commit to Jojo-Schmitz/MuseScore that referenced this pull request Aug 13, 2021
Up to 3.5 it worked only for first line (number="1"), in 3.6 and master it stopped working all together

Backport of musescore#8033, resp. duplicate of musescore#8034. See also musescore#6021
Jojo-Schmitz added a commit to Jojo-Schmitz/MuseScore that referenced this pull request Aug 13, 2021
Jojo-Schmitz added a commit to Jojo-Schmitz/MuseScore that referenced this pull request Aug 19, 2021
Up to 3.5 it worked only for first line (number="1"), in 3.6 and master it stopped working all together

Backport of musescore#8033, resp. duplicate of musescore#8034. See also musescore#6021
Jojo-Schmitz added a commit to Jojo-Schmitz/MuseScore that referenced this pull request Aug 19, 2021
Jojo-Schmitz added a commit to Jojo-Schmitz/MuseScore that referenced this pull request Aug 19, 2021
Up to 3.5 it worked only for first line (number="1"), in 3.6 and master it stopped working all together

Backport of musescore#8033, resp. duplicate of musescore#8034. See also musescore#6021
Jojo-Schmitz added a commit to Jojo-Schmitz/MuseScore that referenced this pull request Aug 19, 2021
Jojo-Schmitz added a commit to Jojo-Schmitz/MuseScore that referenced this pull request Aug 30, 2021
Up to 3.5 it worked only for first line (number="1"), in 3.6 and master it stopped working all together

Backport of musescore#8033, resp. duplicate of musescore#8034. See also musescore#6021
Jojo-Schmitz added a commit to Jojo-Schmitz/MuseScore that referenced this pull request Aug 30, 2021
Jojo-Schmitz added a commit to Jojo-Schmitz/MuseScore that referenced this pull request Sep 1, 2021
Up to 3.5 it worked only for first line (number="1"), in 3.6 and master it stopped working all together

Backport of musescore#8033, resp. duplicate of musescore#8034. See also musescore#6021
Jojo-Schmitz added a commit to Jojo-Schmitz/MuseScore that referenced this pull request Sep 1, 2021
Jojo-Schmitz added a commit to Jojo-Schmitz/MuseScore that referenced this pull request Sep 2, 2021
Up to 3.5 it worked only for first line (number="1"), in 3.6 and master it stopped working all together

Backport of musescore#8033, resp. duplicate of musescore#8034, part 1. See also musescore#6021
Jojo-Schmitz added a commit to Jojo-Schmitz/MuseScore that referenced this pull request Sep 2, 2021
Jojo-Schmitz added a commit to Jojo-Schmitz/MuseScore that referenced this pull request Sep 10, 2021
Up to 3.5 it worked only for first line (number="1"), in 3.6 and master it stopped working all together

Backport of musescore#8033, resp. duplicate of musescore#8034, part 1. See also musescore#6021
Jojo-Schmitz added a commit to Jojo-Schmitz/MuseScore that referenced this pull request Sep 10, 2021
Jojo-Schmitz added a commit to Jojo-Schmitz/MuseScore that referenced this pull request Sep 23, 2021
Up to 3.5 it worked only for first line (number="1"), in 3.6 and master it stopped working all together

Backport of musescore#8033, resp. duplicate of musescore#8034, part 1. See also musescore#6021
Jojo-Schmitz added a commit to Jojo-Schmitz/MuseScore that referenced this pull request Sep 23, 2021
Jojo-Schmitz added a commit to Jojo-Schmitz/MuseScore that referenced this pull request Mar 5, 2023
Up to 3.5 it worked only for first line (number="1"), in 3.6 and master it stopped working all together

Backport of musescore#8033, resp. duplicate of musescore#8034, part 1. See also musescore#6021
Jojo-Schmitz added a commit to Jojo-Schmitz/MuseScore that referenced this pull request Mar 5, 2023
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.

4 participants