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 realtime noteentry 8th crash (fixes #321716) #9593

Closed

Conversation

fxthomas
Copy link
Contributor

@fxthomas fxthomas commented Oct 27, 2021

Resolves: https://musescore.org/en/node/321716

To reproduce (on MuseScore 3.6.2):

  • Connect MIDI keyboard (via JACK/Pipewire in my case)
  • Enter Realtime (Manual) note input mode
  • Select "8th notes"
  • Enter 1 note and hit the manual input button 4 times on the MIDI keyboard, the 4th makes MuseScore crash

  • [?] 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

When comparing a Fraction (ticks2measureEnd) to the TDuration of the note being entered
(is.duration()), the Fraction is implicitly converted by the TDuration(const Fraction&) ctor.
Because of extra logic in TDuration, this can trigger a Q_ASSERT and crash Musescore in case the
remaining Fraction cannot be exactly converted into a proper TDuration.  In this case, this point is
reached when ticks2measureEnd = 5/8 and is.duration() = 1/8.

Since what we really want here is to compare the Fraction to the exact note duration (and not the
other way around), we can just do an exact comparison between is.duration().fraction() and
ticks2measureEnd to achieve the same goal.
@fxthomas
Copy link
Contributor Author

The linked issue should be pretty self-explanatory, and this definitely fixes the issue for me, but I'm not familiar at all with MuseScore development.

How should I go about getting this included in the next point release? In particular, is it OK if I just check the checkmark here to signify that I agree to the CLA for this commit only? How should I go about adding tests here?

@Jojo-Schmitz
Copy link
Contributor

Jojo-Schmitz commented Oct 27, 2021

Better rebase the PR to the master branch. There won't be any merges to the 3.6.2 branch and most probably not to the 3.x branch either (I've git cherry-picked it into my PR #9000 though)

You do need to sign the CLA though, on musescore.org.

Jojo-Schmitz pushed a commit to Jojo-Schmitz/MuseScore that referenced this pull request Oct 27, 2021
When comparing a Fraction (ticks2measureEnd) to the TDuration of the note being entered
(is.duration()), the Fraction is implicitly converted by the TDuration(const Fraction&) ctor.
Because of extra logic in TDuration, this can trigger a Q_ASSERT and crash Musescore in case the
remaining Fraction cannot be exactly converted into a proper TDuration.  In this case, this point is
reached when ticks2measureEnd = 5/8 and is.duration() = 1/8.

Since what we really want here is to compare the Fraction to the exact note duration (and not the
other way around), we can just do an exact comparison between is.duration().fraction() and
ticks2measureEnd to achieve the same goal.

Intgration of PR musescore#9593
Jojo-Schmitz pushed a commit to Jojo-Schmitz/MuseScore that referenced this pull request Oct 27, 2021
When comparing a Fraction (ticks2measureEnd) to the TDuration of the note being entered
(is.duration()), the Fraction is implicitly converted by the TDuration(const Fraction&) ctor.
Because of extra logic in TDuration, this can trigger a Q_ASSERT and crash Musescore in case the
remaining Fraction cannot be exactly converted into a proper TDuration.  In this case, this point is
reached when ticks2measureEnd = 5/8 and is.duration() = 1/8.

Since what we really want here is to compare the Fraction to the exact note duration (and not the
other way around), we can just do an exact comparison between is.duration().fraction() and
ticks2measureEnd to achieve the same goal.

Integration of PR musescore#9593
@fxthomas
Copy link
Contributor Author

fxthomas commented Oct 27, 2021

Thank you, that's one big PR but I'm glad some of the issues of 3.6.3 are getting fixed while 4.0 is being worked on!

I'm very much okay with it in the context of this small bugfix, hence the PR, but I was a bit iffy about signing the CLA irrevocably, that particular bit sounds like it just ignores the GPL for any contribution (which is never actually defined in that document...) that I might later do close to MuseScore:

You grant MuseScore BVBA the ability to use the Contributions in any way.

Trivial contributions (which this is IMO) should be fine, according to this:

All past and future contributors of non-trivial amounts of code (more than just a line or two) to MuseScore are required to sign the CLA. If somebody is unable to sign the document, their contribution will not be accepted or will be removed from MuseScore.

Jojo-Schmitz pushed a commit to Jojo-Schmitz/MuseScore that referenced this pull request Oct 27, 2021
When comparing a Fraction (ticks2measureEnd) to the TDuration of the note being entered
(is.duration()), the Fraction is implicitly converted by the TDuration(const Fraction&) ctor.
Because of extra logic in TDuration, this can trigger a Q_ASSERT and crash Musescore in case the
remaining Fraction cannot be exactly converted into a proper TDuration.  In this case, this point is
reached when ticks2measureEnd = 5/8 and is.duration() = 1/8.

Since what we really want here is to compare the Fraction to the exact note duration (and not the
other way around), we can just do an exact comparison between is.duration().fraction() and
ticks2measureEnd to achieve the same goal.

Integration of PR musescore#9593
Jojo-Schmitz pushed a commit to Jojo-Schmitz/MuseScore that referenced this pull request Oct 27, 2021
When comparing a Fraction (ticks2measureEnd) to the TDuration of the note being entered
(is.duration()), the Fraction is implicitly converted by the TDuration(const Fraction&) ctor.
Because of extra logic in TDuration, this can trigger a Q_ASSERT and crash Musescore in case the
remaining Fraction cannot be exactly converted into a proper TDuration.  In this case, this point is
reached when ticks2measureEnd = 5/8 and is.duration() = 1/8.

Since what we really want here is to compare the Fraction to the exact note duration (and not the
other way around), we can just do an exact comparison between is.duration().fraction() and
ticks2measureEnd to achieve the same goal.

Integration of PR musescore#9593
@Jojo-Schmitz
Copy link
Contributor

Jojo-Schmitz commented Oct 28, 2021

The CLA doesn't change anything about the MuseScore code being under GPL (GPL2 for 3.x, GPL3 for master), only whether parts of the code can also get used in other closed source stuff, like the mobile apps. At least that's my understanding.
Whether or not this code changes gets accepted (with or withoug the CLA) is not my call though.
It for sure won't get merged into the 3.6.2 branch, which is a dead end road (and none of the tests of builds on GitHub CI are run against it). No real need for it in the 3.x branch either (there's unfortunately, no futher 3.x version planned), only usefull thing would be the master branch, so it'd be in MuseScore 4.

@fxthomas
Copy link
Contributor Author

fxthomas commented Nov 6, 2021

Gotcha, I've thought about it and don't want to sign the CLA. Thanks for the help in any case!

@Jojo-Schmitz
Copy link
Contributor

It'd still need to get rebased onto master.

Jojo-Schmitz pushed a commit to Jojo-Schmitz/MuseScore that referenced this pull request Nov 23, 2021
When comparing a Fraction (ticks2measureEnd) to the TDuration of the note being entered
(is.duration()), the Fraction is implicitly converted by the TDuration(const Fraction&) ctor.
Because of extra logic in TDuration, this can trigger a Q_ASSERT and crash Musescore in case the
remaining Fraction cannot be exactly converted into a proper TDuration.  In this case, this point is
reached when ticks2measureEnd = 5/8 and is.duration() = 1/8.

Since what we really want here is to compare the Fraction to the exact note duration (and not the
other way around), we can just do an exact comparison between is.duration().fraction() and
ticks2measureEnd to achieve the same goal.

Integration of PR musescore#9593
Jojo-Schmitz pushed a commit to Jojo-Schmitz/MuseScore that referenced this pull request Nov 24, 2021
When comparing a Fraction (ticks2measureEnd) to the TDuration of the note being entered
(is.duration()), the Fraction is implicitly converted by the TDuration(const Fraction&) ctor.
Because of extra logic in TDuration, this can trigger a Q_ASSERT and crash Musescore in case the
remaining Fraction cannot be exactly converted into a proper TDuration.  In this case, this point is
reached when ticks2measureEnd = 5/8 and is.duration() = 1/8.

Since what we really want here is to compare the Fraction to the exact note duration (and not the
other way around), we can just do an exact comparison between is.duration().fraction() and
ticks2measureEnd to achieve the same goal.

Integration of PR musescore#9593
Jojo-Schmitz pushed a commit to Jojo-Schmitz/MuseScore that referenced this pull request Nov 28, 2021
When comparing a Fraction (ticks2measureEnd) to the TDuration of the note being entered
(is.duration()), the Fraction is implicitly converted by the TDuration(const Fraction&) ctor.
Because of extra logic in TDuration, this can trigger a Q_ASSERT and crash Musescore in case the
remaining Fraction cannot be exactly converted into a proper TDuration.  In this case, this point is
reached when ticks2measureEnd = 5/8 and is.duration() = 1/8.

Since what we really want here is to compare the Fraction to the exact note duration (and not the
other way around), we can just do an exact comparison between is.duration().fraction() and
ticks2measureEnd to achieve the same goal.

Integration of PR musescore#9593
Jojo-Schmitz pushed a commit to Jojo-Schmitz/MuseScore that referenced this pull request Nov 30, 2021
When comparing a Fraction (ticks2measureEnd) to the TDuration of the note being entered
(is.duration()), the Fraction is implicitly converted by the TDuration(const Fraction&) ctor.
Because of extra logic in TDuration, this can trigger a Q_ASSERT and crash Musescore in case the
remaining Fraction cannot be exactly converted into a proper TDuration.  In this case, this point is
reached when ticks2measureEnd = 5/8 and is.duration() = 1/8.

Since what we really want here is to compare the Fraction to the exact note duration (and not the
other way around), we can just do an exact comparison between is.duration().fraction() and
ticks2measureEnd to achieve the same goal.

Integration of PR musescore#9593
Jojo-Schmitz pushed a commit to Jojo-Schmitz/MuseScore that referenced this pull request Dec 7, 2021
When comparing a Fraction (ticks2measureEnd) to the TDuration of the note being entered
(is.duration()), the Fraction is implicitly converted by the TDuration(const Fraction&) ctor.
Because of extra logic in TDuration, this can trigger a Q_ASSERT and crash Musescore in case the
remaining Fraction cannot be exactly converted into a proper TDuration.  In this case, this point is
reached when ticks2measureEnd = 5/8 and is.duration() = 1/8.

Since what we really want here is to compare the Fraction to the exact note duration (and not the
other way around), we can just do an exact comparison between is.duration().fraction() and
ticks2measureEnd to achieve the same goal.

Integration of PR musescore#9593
@yajo
Copy link

yajo commented Dec 29, 2021

I'm just here to say thanks and please merge if possible, this issue is very annoying... 😓

@Jojo-Schmitz
Copy link
Contributor

Jojo-Schmitz commented Dec 29, 2021

There won't be any further 3.x release, but you can try the artifacts from PR #9000.

As this PR here has not yet been ported to master (which will become MuseSDcore 4), the fix won't be there either

Edit: I've now submitted #10199 to get this fix into master

Jojo-Schmitz pushed a commit to Jojo-Schmitz/MuseScore that referenced this pull request Dec 29, 2021
@yajo
Copy link

yajo commented Dec 29, 2021

So you mean that #9000 will never be merged and than this PR should be rebased on top of master to be merged?

@Jojo-Schmitz
Copy link
Contributor

Jojo-Schmitz commented Dec 29, 2021

Yes, neither this PR here nor #9000 are going to get merged. #10199 might.

@yajo
Copy link

yajo commented Dec 29, 2021

Thanks! Then maybe this can be closed...

@Jojo-Schmitz
Copy link
Contributor

Indeed.

Jojo-Schmitz pushed a commit to Jojo-Schmitz/MuseScore that referenced this pull request May 12, 2022
When comparing a Fraction (ticks2measureEnd) to the TDuration of the note being entered
(is.duration()), the Fraction is implicitly converted by the TDuration(const Fraction&) ctor.
Because of extra logic in TDuration, this can trigger a Q_ASSERT and crash Musescore in case the
remaining Fraction cannot be exactly converted into a proper TDuration.  In this case, this point is
reached when ticks2measureEnd = 5/8 and is.duration() = 1/8.

Since what we really want here is to compare the Fraction to the exact note duration (and not the
other way around), we can just do an exact comparison between is.duration().fraction() and
ticks2measureEnd to achieve the same goal.

Integration of PR musescore#9593
Jojo-Schmitz pushed a commit to Jojo-Schmitz/MuseScore that referenced this pull request Mar 5, 2023
When comparing a Fraction (ticks2measureEnd) to the TDuration of the note being entered
(is.duration()), the Fraction is implicitly converted by the TDuration(const Fraction&) ctor.
Because of extra logic in TDuration, this can trigger a Q_ASSERT and crash Musescore in case the
remaining Fraction cannot be exactly converted into a proper TDuration.  In this case, this point is
reached when ticks2measureEnd = 5/8 and is.duration() = 1/8.

Since what we really want here is to compare the Fraction to the exact note duration (and not the
other way around), we can just do an exact comparison between is.duration().fraction() and
ticks2measureEnd to achieve the same goal.

Integration of PR musescore#9593
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